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

CCMenu with no Items #31

Open irwinb opened 13 years ago

irwinb commented 13 years ago

Currently, if you instantiate a CCMenu without any children and add it to another node, the code flips out during some operations (ex. itemForTouch) because its list of children is null.

Maybe add some null checks or..ditch the lazy allocations? I'm not sure.

It would be nice if you are able to add CCMenu's to other nodes without the menu having any children..unless that is against the cocos2d spec. There are cases where it would be ideal to have an empty menu where the items get added later on due to some game logic.

Thanks!

ZhouWeikuan commented 13 years ago

Yes, I have tried to add a CCMenu with null argument to accompy this, but there may still be some bugs, Welcome any bug report and/or patch!

2011/8/17 irwinb < reply@reply.github.com>

Currently, if you instantiate a CCMenu without any children and add it to another node, the code flips out during some operations (ex. itemForTouch) because its list of children is null.

Maybe add some null checks or..ditch the lazy allocations? I'm not sure.

It would be nice if you are able to add CCMenu's to other nodes without the menu having any children..unless that is against the cocos2d spec. There are cases where it would be ideal to have an empty menu where the items get added later on due to some game logic.

Thanks!

Reply to this email directly or view it on GitHub: https://github.com/ZhouWeikuan/cocos2d/issues/31