Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. let bullet = SKSpriteNode(fileNamed: "Bullet")
  2. bullet?.size = CGSize(width: 100, height: 100)
  3. bullet.zPosition = -5
  4.  
  5. bullet.position = CGPointMake(player.position.x, player.position.y)
  6. bullet.zRotation = player.zRotation
  7.  
  8.  
  9. let action = SKAction.moveToY(self.size.height + 30, duration: 0.8)
  10. let actionDone = SKAction.removeFromParent()
  11. bullet.runAction(SKAction.sequence([action, actionDone]))
  12.  
  13. bullet.physicsBody = SKPhysicsBody(rectangleOfSize: bullet.size)
  14. bullet.physicsBody?.affectedByGravity = false
  15. bullet.physicsBody?.dynamic = false
  16. self.addChild(bullet)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement