美文网首页
2018-01-09 Sprite学习笔记-1

2018-01-09 Sprite学习笔记-1

作者: Sesshomaru | 来源:发表于2018-01-09 15:41 被阅读253次
    1. 通过Code初始化View及Scene的方法
    override func viewDidLoad() {
            super.viewDidLoad()
            
            //Initialize scene
            let scene = GameScene(size: CGSize(width: 1920, height: 1080))
            
            //Initialize skView
            let skView = self.view as! SKView
            
            //Set FPS & node count present in the scene
            skView.showsFPS = true
            
            skView.showsNodeCount = true
            
            //A Boolean value that indicates whether parent-child and sibling relationships affect the rendering order of nodes in the scene.
            skView.ignoresSiblingOrder = true
            
            //Set the scaleMode
            scene.scaleMode = .aspectFill
            
            //Present scene in skView
            skView.presentScene(scene)
           
            
        }
    
    
    1. Sprite在scene中不考虑其他因素的自然移动,需在update()方法中添加:
    zombie.position =  CGPoint(x: zombie.position.x+1, y: zombie.position.y)
    

    相关文章

      网友评论

          本文标题:2018-01-09 Sprite学习笔记-1

          本文链接:https://www.haomeiwen.com/subject/eqfgnxtx.html