Cocos2D - CCAnimation:现在正在显示哪一帧?

发布于 2024-12-10 12:25:42 字数 324 浏览 0 评论 0原文

我正在做一个精灵动画。代码是:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔戏命师 2024-12-17 12:25:42

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文