Rob为子类化NSOperation 提供了一个很好的Objective-C解决方案,以实现SKAction对象的串行排队机制.我在自己的Swift项目中成功实现了这一点.
import SpriteKit
class ActionOperation : NSOperation
{
let _node: SKNode // The sprite node on which an action is to be performed
let _action: SKAction // The action to perform on the sprite node
var _finished = false // Our read-write mirror of the super's read-only finished property
var _executing = false // Our read-write mirror of the super's read-only executing property
/// Override read-only superclass property as read-write.
override var executing: Bool {
get …Run Code Online (Sandbox Code Playgroud)