How to make camera follow SKNode in Sprite Kit?

后端 未结 6 2091
庸人自扰
庸人自扰 2020-12-08 23:21

I want to have background stationary with different objects (sprites and other objects).

Player will be represented by center node that will move around the world. I

6条回答
  •  悲&欢浪女
    2020-12-08 23:44

    Using SKCameraNode with SKConstraint in Swift 5.1

    let camera = SKCameraNode()
    camera.constraints = [.distance(.init(upperLimit: 10), to: node)]
    scene.addChild(camera)
    scene.camera = camera
    

提交回复
热议问题