复制CCSprite? (cocos2d)
我正在尝试复制一个已子类化的 CCSprite。假设该文件名为 Names。原来的变量名为 bob。如果你想复制鲍勃的所有动作,你会怎么做?我的意思是复制一个 CCSprite 并使其具有与原始 CCSprite 相同的操作和属性。我想我必须将操作添加为属性?你怎么做到的?我需要能够多次复制“bob”。
谢谢!
I'm trying to copy a CCSprite that's been subclassed. Let's say the file is called Names. And the original variable name is bob. If you wanted to copy all the actions of bob, how would you do that? By that I mean duplicating a CCSprite and have it have the same actions and attributes the original one has. I think I have to add the action as a property? How do you do that? I'd need to be able to copy "bob" many times.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有操作都存储在
CCActionManager
中。目前还没有功能可以获取与对象关联的所有操作,但您可以添加一个方法来执行此操作 - 请查看GetActionByTag
和NumberOfRunningActionsInTarget
。获得操作列表后,您可以执行并复制它们。您需要为精灵子类以及动作编写一个复制函数。
All actions are stored in the
CCActionManager
. There isn't functionality right now to get all of the actions associated with an object but you could add a method to do so - look atGetActionByTag
andNumberOfRunningActionsInTarget
.Once you get a list of the actions you can go through and copy them. You'll want to write a copy function that for the sprite subclass as well as the actions.