Cocos2D - CCAnimation:现在正在显示哪一帧?
我正在做一个精灵动画。代码是:
CCAnimation *anim = [CCAnimation animationWithFrames:frames delay: 0.1f];
CCAnimate *animate = [CCAnimate actionWithAnimation:anim];
CCRepeatForever *repeat = [CCRepeatForever actionWithAction:animate];
[sprite runAction: repeat];
我想知道当我点击精灵时正在显示动画的哪一帧。我怎样才能做到这一点?谢谢。
I'm doing a sprite animation. The code is:
CCAnimation *anim = [CCAnimation animationWithFrames:frames delay: 0.1f];
CCAnimate *animate = [CCAnimate actionWithAnimation:anim];
CCRepeatForever *repeat = [CCRepeatForever actionWithAction:animate];
[sprite runAction: repeat];
I want to know which frame of the animation is being displayed when I click on the sprite. How can I do that? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 CCSprite 方法 isFrameDisplayed 将当前的 CCSpriteFrame 与另一个进行比较。您必须保留帧数组才能进行稍后的比较。不幸的是,Cocos2D 不支持测试特定动画的第 n 帧是否立即显示,也不告诉您当前显示的 CCSpriteFrame 的文件名。
You can use the CCSprite method isFrameDisplayed to compare the current CCSpriteFrame with another. You'll have to keep the frames array around to do the later comparison. Unfortunately Cocos2D does not support testing if the n-th frame of a particular animation is displayed out of the box, nor does it tell you the filename of the currently displayed CCSpriteFrame.