【问题标题】:SKAction display single image for duration?SKAction 持续显示单个图像?
【发布时间】:2013-09-26 11:36:36
【问题描述】:
SKAction *ghostAnimationAction = 
[SKAction animateWithTextures:ghostFrames timePerFrame:0.1];

SKAction *ghostDelayAction = 
[SKAction animateWithTextures:@[[SKTexture textureWithImageNamed:@"Ghost_"]]     
timePerFrame:1.0];

SKAction *ghostAnimationSequence = 
[SKAction sequence:@[ghostAnimationAction, ghostDelayAction]];

SKAction *repeatGhostAnimationSequence = 
[SKAction repeatActionForever:ghostAnimationSequence];

我有一个由NSMutableArraySKTexture 对象组成的动画帧序列。播放完该序列后,我想在静止帧上折叠一秒钟,然后再重复所有内容。上面的代码有效,但我能找到指定在帧上保持一段时间的唯一方法是使用 animateWithTextures:timePerFrame: 并提供单个纹理数组。是否有另一种方法可以让SKAction 在我错过的时间内显示单个图像。

【问题讨论】:

  • 请原谅格式,代码字段不会滚动,只是截断了文本,不知道为什么会像以前那样工作。

标签: iphone ios objective-c sprite-kit skaction


【解决方案1】:

您可以创建一个包含这两个操作的新 SKAction。请参阅名为 'Creating Actions That Run Other Actions' 的 Sprite Kit 编程指南部分 Adding Actions To Nodes

看看 SKAction 成员 waitForDuration: 也一样,您也许可以避免以这种方式传入单个纹理。让第一个 SKAction 运行您的动画,然后让第二个 SKAction waitForDuration。然后,您的封闭 SKAction 将永远或根据需要运行这两个操作。

【讨论】:

  • 啊,waitForDuration:听起来像我需要的,我去看看。非常感谢。
猜你喜欢
  • 1970-01-01
  • 2015-05-12
  • 1970-01-01
  • 1970-01-01
  • 2013-11-22
  • 2015-05-11
  • 1970-01-01
  • 2013-03-15
  • 1970-01-01
相关资源
最近更新 更多