简体   繁体   English

带Cocos2d的动态CCMenu

[英]Dynamic CCMenu with Cocos2d

I wanted to create a menu in cocos2d in which the menu items would drift through the screen, disappear, and then re-appear. 我想在cocos2d中创建一个菜单,其中菜单项将在屏幕中漂移,消失然后重新出现。 I haven't been able to find anything that showed the CCMenuItem's animating, or moving. 我一直找不到能显示CCMenuItem动画或移动的东西。 Is this possible to do? 这可能吗? Or would I be better to use CCSprites and just create functions to switch scene's when they are touched? 还是我会更好地使用CCSprites并创建函数以在触摸场景时切换场景?

You can use CCMenuItemSprite (a subclass of CCMenuItem) to achieve this. 您可以使用CCMenuItemSprite(CCMenuItem的子类)来实现此目的。 Go ahead and create your sprites (and apply actions to them if you like) and then use those sprites to create the CCMenuItemSprite. 继续创建精灵(如果愿意,可以对它们应用操作),然后使用这些精灵创建CCMenuItemSprite。 But if you want to change the actions later, you'll need to hang on to a pointer to the CCSprite--that's what controls the action (not the CCMenuItemSprite). 但是,如果您以后想要更改操作,则需要挂起指向CCSprite的指针-这是控制操作的对象(而不是CCMenuItemSprite)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM