Cli*_*Lam 12 sprite-kit skaction swift
以下代码将为旋转设置动画.
let something:SKSpriteNode = SKSpriteNode()
func start(){
let rotateAction = SKAction.rotateToAngle(CGFloat(M_PI), duration: 10.0)
something.runAction(SKAction.sequence([rotateAction]))
}
Run Code Online (Sandbox Code Playgroud)
现在我想在动画持续时间内停止动画.有什么类似于以下内容吗?我想在用户触摸屏幕时停止动画.
func stop(){
something.SKAction.stop()
}
Run Code Online (Sandbox Code Playgroud)
Jea*_*nès 17
你只需要使用:
something.paused = false // or true 暂停节点上的操作something.removeAllActions() 绝对删除与节点关联的操作something.runAction(action,withKey:"action1"),然后something.removeActionForKey("action1")删除给定的操作如果需要,您也可以更改速度.
首先,使用密钥运行该操作,以便您以后可以识别它:
something.runAction(rotateAction, withKey: "rotate action")
Run Code Online (Sandbox Code Playgroud)
然后你可以稍后通过调用停止它
something.removeActionForKey("rotate action")
Run Code Online (Sandbox Code Playgroud)
或者,您也可以删除所有操作
something.removeAllActions()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9962 次 |
| 最近记录: |