Cocos2d: Calling function from one CCLayer in another (parent?) CCLayer -


hello awesome dev community. have looked answer days , can't seem find handle, decided post q myself.

i have game has menus picking items. menus can have 2 -> 30+ items, need scroll. there category menus, when item clicked, new menu category's items appears.

i figured efficient way go creating elements needed menu on dedicated layer. issue have no idea how call addnewitems:itemsarray function defined in main game scene, cclayer containing menu.

or, should use 1 layer? bit messy , difficult move multiple items together.

thank - or pointing me in direction of clear tutorial or examples of how since couldn't find any.

below flowchart of i'm looking create.

thanks!!

hanaan

alt text

finally got answer david994a (cocos2d forum)

the answer pass layer pointer it's parent layer initialize cclayer this:

-(id) initwithparent:(cclayer *)parentlayer;

and call this:

itemsmenulayer *templayer = [[itemsmenulayer alloc] initwithparent:self];

then, inside cclayer can call of parent's layer functions, this:

[parentlayer functionname];


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -