ios - Spritekit 运动轨迹

标签 ios sprite-kit

在我最近的 Spritekit 项目中,我想要一个用户可以移动的节点,它显示如下移动轨迹

我正在考虑使用 SKEmitterNode 来实现这一点,但是粒子之间并没有那么“分离”

enter image description here

最佳答案

尝试留下原始 Sprite 的 x 个副本,但启动 SKAction 将 alpha 淡化为 0,并可能将大小也缩放为 0。创建一个 NSTimer 以在一两秒后删除旧的 Sprite 。将这段代码放在你移动你想要尾部的主要 Sprite 的地方

//copy the sprite that is moving around
let newSprite = theMovingNode.copy()

//fade and shrink our new sprite
newSprite.runAction(SKAction.FadeAlphaTo(0,duration:2.0))
newSprite.runAction(SKAction.ScaleTo(0,duration:2.0))

// create a timer to remove this sprite in 2 seconds
let timer = NSTimer.scheduledTimerWithTimeInterval(2, target: self, selector: Selector("removeTailSprite:"), userInfo: newSprite, repeats: false)

关于ios - Spritekit 运动轨迹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33271958/

相关文章:

ios - 对持续触摸采取行动,而不是仅在触摸开始时采取行动 :

swift - 如何在一组同名的 SKSpriteNode 上运行 SKAction?

ios - 为什么 applicationWillResignActive 方法不起作用?

ios - 调用了 UICollectionView cellForItemAtIndexPath 但数据源为空

ios - 如何每天每天重复几个小时的本地通知?

ios - Twilio 的 "Programmable Video"是如何工作的?

android - 面向 iOS、Android 和 WP7 的 Web 应用程序?

ios - 使用 SpriteKit 和 UITextView 的 UITextSelectionView 名称无法识别的选择器

swift - 在 SpriteKit 游戏中使用 didBeginContact 的正确方法 - Swift

swift - SpriteKit - 获取 SKNode 的绝对大小