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

  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)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容