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
How to Add Android Widgets (E.g Gallery) to a CCLayer #62
Hi, what would be the best way to add an android widget to a CCLayer. I have tried using CCDirector.sharedDirector().attachInView(mygaller), have tried passing a reference to the original activity and calling .addView on it, but still it doesnt work. Rather my game just hangs there and does load the next layer (and no error is shown on the debug screen). I believe there should be a work around to this, or a proper design principle which I am unfamiliar with.
I would greatly appreciate some assistance.
After some extra search (and also looking through some Cocos2dIphone forums) I realized two things.
The general design philosophy of the Cocos2d library leans towards enabling developers make complete games without ever having to depend on android widgets. Given that the widgets are not sub-classes of CCNode, adding them to CCLayer (from my point of view) isn't really supported. What I have learned is that almost everything needed is available within the Cocos2D library - a little hack here and there might just be necessary to get it to taste
I originally wanted to add the gallery widget in order to implement AngryBirds style level menus in my game. I had an old version of cocos2d which did not have the scrollview class. I just stumbled across it and currently using it to implement my scrollable menu.
Many thanks to Rodrigo Collavo for making this valuable contribution and hence solving my problem.
Hi, what would be the best way to add an android widget to a CCLayer. I have tried using CCDirector.sharedDirector().attachInView(mygaller), have tried passing a reference to the original activity and calling .addView on it, but still it doesnt work. Rather my game just hangs there and does load the next layer (and no error is shown on the debug screen). I believe there should be a work around to this, or a proper design principle which I am unfamiliar with. I would greatly appreciate some assistance.