ZhouWeikuan / cocos2d

cocos2d for android, based on cocos2d-android-0.82, and now ported from cocos2d-iphone 0.99.4. The googlecode address is here: http://code.google.com/p/cocos2d-android-1/ . There are several demos to watch.
610 stars 291 forks source link

CCMenuItem and CCMenuItemSprite #49

Open Jimmar opened 12 years ago

Jimmar commented 12 years ago

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"

ZhouWeikuan commented 12 years ago

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: https://github.com/ZhouWeikuan/cocos2d/issues/49

This is Zhou, Weikuan(Ϊ)