开发者

How to access a CCMenuItemImage from a CCMenu

I have a CCMenu that contains a CCMenuItemImage named pauseButton and a CCMenuItemImage named playButton. I need to be able to access the pauseButton and playButton, but once I add them to the CCMenu开发者_JAVA百科 they disappear. I have set their tags and try to access them through [self getChildByTag:1], but the debugger says that nothing contains the tag. How can I access the members of the CCMenu?


What is the name of your CCMenu variable? If you code looks something like this:

CCMenu *menu = [CCMenu menuWithItems:playButton, pauseButton, nil];

Then you would access the play button or pause button with [menu getChildByTag:1] not [self getChildByTag:1]. Otherwise, if you make a reference to playButton or pauseButton as a instance variable of the class or as a property, you should be able to access then directly, even if you add them to the menu.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜