Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- import SpriteKit
- class ShooterScene: SKScene {
- var score = 0
- var enemyCount = 10
- var shooterAnimation = [SKTexture]()
- override func didMoveToView(view: SKView) {
- self.initShooterScene()
- }
- func initShooterScene(){
- let shooterAtlas = SKTextureAtlas(named: "shooter")
- for index in 1...shooterAtlas.textureNames.count {
- let imgName = String(format: "shooter%01d", index)
- shooterAnimation += [shooterAtlas.textureNamed(imgName)]
- }
- }
- // Animate the shooter:
- override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
- let shooterNode = self.childNodeWithName("shooterNode")
- if(shooterNode != nil){
- let animation = SKAction.animateWithTextures(shooterAnimation, timePerFrame: 0.1)
- shooterNode?.runAction(animation)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement