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


    根据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

  • 相关阅读:
    Linux下挂载新硬盘
    远程编写+调试服务器上的Python程序
    记一次CUDA编程任务
    CUDA核函数调用基础数学API的一个奇葩情况
    Python多线程常用包对比
    Python threadpool传递参数
    代码生成器
    从移动优先到离线优先(三)
    从移动优先到离线优先(二)
    从移动优先到离线优先(一)
  • 原文地址:https://www.cnblogs.com/apiapia/p/9418399.html
Copyright © 2020-2023  润新知