码迷,mamicode.com
首页 > 其他好文 > 详细

SpriteKit在复制节点时留了一个巨坑给开发者,需要开发者手动把复制节点的isPaused设置为false

时间:2018-08-04 14:33:06      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:mes   mit   pie   RoCE   开发者   instance   sha   sed   pause   

根据When an overlay node with actions is copied there is currently a SpriteKit bug where the node’s isPaused property might be set to true提示,SpriteKit有一个Bug需要开发者自己来填。

SpriteNode节点在被copy()复制后,会自动被设置为暂停,也就是节点的所有Action全部不可用,如果需要使用node.run(SKAction.run{//code})

需要把复制后的节点isPaused设置为false

需要把复制后的节点isPaused设置为false

需要把复制后的节点isPaused设置为false

重要的事情说三遍 !!!

let overlayScene = SKScene(fileNamed: "ShoseScene")!
        let overlayShose = overlayScene.childNode(withName: "Overlay") as! SKSpriteNode
        let gameSceneOverlay = overlayShose.copy() as! SKSpriteNode
        overlayShose.removeFromParent() // 移除旧的
        /* 留意SpirteKit的巨坑
         * When an overlay node with actions is copied  there is currently a SpriteKit bug
         * where the node’s isPaused property might be set to true
         * 一定要记得设置为 false 或者所有gamesceneOverlay内的子节点的所有action都不起作用
         */
        gameSceneOverlay.isPaused = false;
        gameSceneOverlay.enumerateChildNodes(withName: "shose") { (node, _) in
            let sprite = node as! ShoseNodeClass
            sprite.newInstance(scene: self.scene!) // 加入物理体;
        }

使用的场景

  // 特效果汁
    func emitParticles(particleName: String, sprite: SKSpriteNode) {
       // isPaused =false 后,获得的sprite才可以运行.run,否则不起作用;
        sprite.run(SKAction.run({
            sprite.removeFromParent()
            print ("精灵节点内 hit shoses")
        }))
    }

更多Swfit游戏教学:http://www.iFIERO.com

SpriteKit在复制节点时留了一个巨坑给开发者,需要开发者手动把复制节点的isPaused设置为false

标签:mes   mit   pie   RoCE   开发者   instance   sha   sed   pause   

原文地址:https://www.cnblogs.com/apiapia/p/9418399.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!