Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. override func update(currentTime: NSTimeInterval) {
  2. if self.camera != nil {
  3. self.camera!.position = CGPointMake(CGRectGetMidX(super.frame) / 10, wayPoints.last!.y)
  4. self.centerOnNode(self.camera!)
  5. }
  6. }
  7.  
  8. func centerOnNode(node: SKNode) {
  9. let cameraPositionInScene: CGPoint = node.scene!.convertPoint(node.position, fromNode: node.parent!)
  10. node.parent!.position = CGPoint(x:node.parent!.position.x - cameraPositionInScene.x, y:node.parent!.position.y - cameraPositionInScene.y)
  11. }
  12.  
  13. NSTimer.scheduledTimerWithTimeInterval(0.05, target: self, selector: "addPoint", userInfo: nil, repeats: true)
  14.  
  15. camera?.position = player!.position
  16. camera?.physicsBody?.velocity = player!.physicsBody!.velocity
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement