检测到碰撞时显示框架(cocos2d iPhone)
我有一个英雄角色,全部设置为 CCSpriteBatchNode,其中包含所有动画和帧。但我想知道,当英雄被击中时如何显示帧(我已经设置了碰撞检测)。我怎样才能做到这一点?我是否将其放入 CCSpriteBatchNode 中?这不是搬家的一部分,仅适用于特殊场合。
I have a hero character all set up with a CCSpriteBatchNode, which has all the animation and frames. But I wonder, how do I display a frame when the hero is hit (I set up collision detection already). How do I make this happen? Do I put it inside the CCSpriteBatchNode? It's not part of moving, only for special occasions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将英雄设置为不可见(
[sprite setVisible: NO]
)并在英雄位置显示另一个精灵。更重要的是,您可以将此精灵保留在英雄类对象中,并提供一个方法,该方法将在发生碰撞时更改可见精灵。像这样
的解决方案也将保留您之前已经完成的所有逻辑。
You can set your hero invisible (
[sprite setVisible: NO]
) and show another sprite at the hero's position.More then it, you can keep this sprite in your hero class object and provide a method which will change the visible sprite when collision happens. Something like this
Such solution will also preserve all your logic, that has been done before.
当英雄被击中时..更改纹理..
它需要与动画的其余部分位于同一批处理节点中..
When hero gets hit.. Change the texture..
It needs to be in the same batch node as the rest of the animation..