0

How can I "center in-game camera" on any SKNode? I'm using Xcode 6, SpriteKit and Swift.

  • This is explained in the Sprite Kit Programming Guide and here: http://stackoverflow.com/questions/20828655/how-to-make-camera-follow-sknode-in-sprite-kit – CodeSmile Oct 14 '14 at 12:10
  • @LearnCocos2D can You please see my another question? It is very important. Please if You have 2 minutes http://stackoverflow.com/questions/27117368 – Andriy Zherebyatyev Nov 25 '14 at 23:01

1 Answers1

0

Try this method:

 func centerOnNode(node:SKNode){

       let cameraPositionInScene:CGPoint = self.convertPoint(node.position, fromNode: mazeWorld!)

       mazeWorld!.position = CGPoint(x:mazeWorld!.position.x - cameraPositionInScene.x, y: mazeWorld!.position.y - cameraPositionInScene.y)
   }


   override func didSimulatePhysics() {
      self.centerOnNode(hero!)
  }
Miki
  • 11
  • 2