Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import UIKit
  2. import SpriteKit
  3.  
  4. class ShooterScene: SKScene {
  5.  
  6. var score = 0
  7. var enemyCount = 10
  8. var shooterAnimation = [SKTexture]()
  9.  
  10. override func didMoveToView(view: SKView) {
  11. self.initShooterScene()
  12. }
  13.  
  14. func initShooterScene(){
  15. let shooterAtlas = SKTextureAtlas(named: "shooter")
  16.  
  17. for index in 1...shooterAtlas.textureNames.count {
  18. let imgName = String(format: "shooter%01d", index)
  19. shooterAnimation += [shooterAtlas.textureNamed(imgName)]
  20.  
  21. }
  22. }
  23.  
  24. // Animate the shooter:
  25. override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
  26. let shooterNode = self.childNodeWithName("shooterNode")
  27.  
  28. if(shooterNode != nil){
  29. let animation = SKAction.animateWithTextures(shooterAnimation, timePerFrame: 0.1)
  30. shooterNode?.runAction(animation)
  31.  
  32. }
  33.  
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement