- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在一个简单的游戏中,一个角色有大约 15 帧的行走动画。基于加速度计的是任一方向的速度变化。我希望动画相应地加速或减慢。我意识到一旦动画初始化,您就无法更改延迟速度,而是需要创建一个新的动画。但由于速度几乎不断变化,如果我不断重置动画,它总是会卡在同一帧上。
有没有办法找到动画当前所在的帧,停止它,然后创建一个具有相同帧但从上一个动画结束的位置开始的新动画?
否则有人知道如何实现动态变化的动画延迟时间吗?
编辑:
我尝试使用 CCSpeed 从 Learn Cocos2d 2 中的示例中执行此操作。代码如下:
CCRepeatForever *walkLeftRepeat = [CCRepeatForever actionWithAction:[CCAnimation animationWithSpriteFrames:walkLeftFrames]];
self.walkLeft = [CCSpeed actionWithAction:walkLeftRepeat speed:animationWalkingSpeed];
我收到以下警告:不兼容的指针类型将“CCRepeatForever *”发送到“CCActionInterval *”类型的参数
这是我遵循的示例:
CCRepeatForever* repeat = [CCRepeatForever actionWithAction:rotateBy];
CCSpeed* speedAction = [CCSpeed actionWithAction:repeat speed:0.5f];
第二次编辑:
然后我尝试了这个:
CCAnimation *walkLeftRepeat = [CCAnimation animationWithSpriteFrames:walkLeftFrames];
CCAnimate *temp = [CCAnimate actionWithAnimation:walkLeftRepeat];
CCAnimate*temp2 = [CCRepeatForever actionWithAction:temp];
self.walkLeft = [CCSpeed actionWithAction:temp2 speed:animationWalkingSpeed];
[_guy runAction:_walkLeft];
最终编辑。它不显示的问题已通过添加延迟来解决。
这不会给出任何错误,但什么也没有发生。谢谢!
最佳答案
无需重新创建动画。使用 CCSpeed Action 并将 CCAnimate Action 作为其内部 Action 。然后您可以修改 CCSpeed Action 的 speed 属性来加快或减慢动画速度。
另一种方法是自己推进框架。这很容易做到,您只需要一个计划的更新和一个计时器来告诉您何时更改到下一帧。您只需更改每帧添加到计时器的数量即可加快或减慢动画速度。如果计时器大于特定值,您将更改帧并将计时器重置为 0。
关于iphone - cocos2d 使用 CCSpeed 动态改变动画速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14251161/
所以我正在尝试将 Cocos2D 示例中的 EaseActionsTest 示例中的 alterTime 方法实现到我的游戏中。 我正在尝试将这个想法实现到我的游戏中,为我的游戏创建一个卡住时间类型的
在一个简单的游戏中,一个角色有大约 15 帧的行走动画。基于加速度计的是任一方向的速度变化。我希望动画相应地加速或减慢。我意识到一旦动画初始化,您就无法更改延迟速度,而是需要创建一个新的动画。但由于速
我是一名优秀的程序员,十分优秀!