ZhouWeikuan/cocos2d

CCMenuItem and CCMenuItemSprite

Jimmar opened this issue · 1 comments

org.cocos2d.menus.CCMenuItemSprite
I don't see why there is an overridden draw() method [line 105] , it was actually causing weird behavior [if the selected sprite was a scaled sprite I'd get 2 overlapping sprites]
I did remove it and it worked properly

org.cocos2d.menus.CCMenuItem
The method invocation doesn't work, it throws a NoSuchMethodException
I changed line 54 from
invocation = cls.getMethod(cb, Object.class);
to
invocation = cls.getMethod(cb);

and line 73 from
invocation.invoke(targetCallback, this);
to
invocation.invoke(targetCallback, null);

which worked but was giving me a warning "The argument of type null should explicitly be cast to Object[] for the invocation of the varargs method invoke(Object, Object...) from type Method. It could alternatively be cast to Object for a varargs invocation"

for the draw(), we transported it from cocos2d-iphone

for the later problem, if you change the callback function
from
public void callback();
to
public void callback(Object sender);

then it should works. cocos2d-iphone can support both functions but we
changed to later since we have to get the CCMenuItem sometimes.

Thanks,
Weikuan Zhou

2011/12/10 JiMMaR <
reply@reply.github.com

org.cocos2d.menus.CCMenuItemSprite
I don't see why there is an overridden draw() method [line 105] , it was
actually causing weird behavior [if the selected sprite was a scaled sprite
I'd get 2 overlapping sprites]
I did remove it and it worked properly

org.cocos2d.menus.CCMenuItem
The method invocation doesn't work, it throws a NoSuchMethodException
I changed line 54 from
invocation = cls.getMethod(cb, Object.class);
to
invocation = cls.getMethod(cb);

and line 73 from
invocation.invoke(targetCallback, this);
to
invocation.invoke(targetCallback, null);

which worked but was giving me a warning "The argument of type null should
explicitly be cast to Object[] for the invocation of the varargs method
invoke(Object, Object...) from type Method. It could alternatively be cast
to Object for a varargs invocation"


Reply to this email directly or view it on GitHub:
#49

This is Zhou, Weikuan(Ϊ)