我希望在父级暂停时让子节点消失。
var plats: SKNode = SKNode();
var bigBox: SKSpriteNode!;
override func didMoveToView(view: SKView) {
// Set anchor point
self.anchorPoint = CGPointMake(0.5, 0.5);
bigBox = SKSpriteNode(color: UIColor.redColor(), size: CGSizeMake(100, 100));
bigBox.zPosition = 1;
plats.addChild(bigBox);
var smallBox: SKSpriteNode = SKSpriteNode(color: UIColor.greenColor(), size: CGSizeMake(50, 50));
smallBox.zPosition = 2;
bigBox.addChild(smallBox);
self.addChild(plats);
}
//检测到触摸时暂停平板并尝试对孩子进行操作
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
// Here I pause the parent
plats.paused = true;
// Get the child node
let smallBox: SKSpriteNode = bigBox.children[0] as! SKSpriteNode;
println(smallBox);
smallBox.paused = false;
println(smallBox.paused); // return false but the action is never trigger
// This part is never run, if I set plats.paused = false it will work but I dont that
let scaleUp = SKAction.scaleTo(0.4, duration: 0.1);
smallBox.runAction(scaleUp, completion: {
self.bigBox.removeAllActions();
self.bigBox.removeFromParent();
println("done");
});
}
多数民众赞成就是所有代码,你可以粘贴并试着看看它是否有效
xcode ver :6.3 swift ver :1.2
答案 0 :(得分:0)
暂停节点后,节点及其所有后代将暂停。换句话说,您无法暂停父节点,并且其中一个子节点继续运行。