Swift 暂停无尽的 SKAction
Swift Pause Endless SKAction
我目前正在制作飞扬的小鸟克隆,并且在我的 didMoveTOView 方法中有一个 SKAction (runActionForever)。但是,一旦我死了,我想终止那个动作,然后弹出一个屏幕。
override func didMoveToView(view: SKView) {
var endlessAction = SKAction.runActionForever(spawn, delay)
}
func died() {
endlessAction..... ?
screenDied.position = CGPoint(self.frame.x / 2, self.frame.y / 2)
addChild(screenDied)
}
现在,在另一个函数 died() 中,我该如何结束这个动作? - 这样我就可以制作一个屏幕弹出窗口。
谢谢!
SKAction Class 参考:http://goo.gl/w6ZEFI
SKNode Class 参考:http://goo.gl/Wn9xGw
向节点添加操作:http://goo.gl/xR9Tfb
To cancel actions that a node is running, call its removeAllActions method. All actions are removed from the node immediately. If a removed action had a duration, any changes it already made to the node remain intact, but further changes are not executed.
Normally, you can’t see which actions a node is executing and if you want to remove actions, you must remove all of them. If you need to see whether a particular action is executing or remove a specific action, you must use named actions. A named action uses a unique key name to identify the action. You can start, remove, find, and replace named actions on a node.
如果您需要从节点中删除所有操作,可以使用removeAllActions
方法。但是,如果您需要删除特定操作,则需要使用名为 runAction:withKey:
.
的方法 运行 它
如果具有相同键的操作已经 运行ning,则在添加新操作之前将其删除。
此外,您可以使用 actionForKey:
查看某个操作是否在特定节点上 运行ning。
然后使用removeActionForKey:
删除操作。
PS :如果您想暂停操作和节点本身,您可能需要在节点上查找 paused
属性 .
我目前正在制作飞扬的小鸟克隆,并且在我的 didMoveTOView 方法中有一个 SKAction (runActionForever)。但是,一旦我死了,我想终止那个动作,然后弹出一个屏幕。
override func didMoveToView(view: SKView) {
var endlessAction = SKAction.runActionForever(spawn, delay)
}
func died() {
endlessAction..... ?
screenDied.position = CGPoint(self.frame.x / 2, self.frame.y / 2)
addChild(screenDied)
}
现在,在另一个函数 died() 中,我该如何结束这个动作? - 这样我就可以制作一个屏幕弹出窗口。
谢谢!
SKAction Class 参考:http://goo.gl/w6ZEFI
SKNode Class 参考:http://goo.gl/Wn9xGw
向节点添加操作:http://goo.gl/xR9Tfb
To cancel actions that a node is running, call its removeAllActions method. All actions are removed from the node immediately. If a removed action had a duration, any changes it already made to the node remain intact, but further changes are not executed.
Normally, you can’t see which actions a node is executing and if you want to remove actions, you must remove all of them. If you need to see whether a particular action is executing or remove a specific action, you must use named actions. A named action uses a unique key name to identify the action. You can start, remove, find, and replace named actions on a node.
如果您需要从节点中删除所有操作,可以使用removeAllActions
方法。但是,如果您需要删除特定操作,则需要使用名为 runAction:withKey:
.
如果具有相同键的操作已经 运行ning,则在添加新操作之前将其删除。
此外,您可以使用 actionForKey:
查看某个操作是否在特定节点上 运行ning。
然后使用removeActionForKey:
删除操作。
PS :如果您想暂停操作和节点本身,您可能需要在节点上查找 paused
属性 .