I put the different images to show in succession in the assets.xcassets folder as shooter, shooter1, shooter2 and so on but whenever i touch the screen the animation/image shown in the view doesn't change?
Here is my code:
import UIKit
import SpriteKit
class ShooterScene: SKScene
{
var score = 0
var enemyCount = 10
var shooterAnimation = [SKTexture]()
override func didMove(to view: SKView)
{
self.initShooterScene()
}
func initShooterScene()
{
let shooterAtlas = SKTextureAtlas(named: "shooter") // referencing shooter.atlas
for index in 1...shooterAtlas.textureNames.count
{
let imgName = "shooter\(index)"
shooterAnimation += [shooterAtlas.textureNamed(imgName)]
}
}
//Animate the shooter
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if let shooterNode = self.childNode(withName: "shooterNode") as? SKSpriteNode
{
let animation = SKAction.animate(with: shooterAnimation, timePerFrame: 0.1)
shooterNode.run(animation)
}
}
}
The sprite node that I use in the view has the name shooterNode but the image doesn't seem to change at all. Any help would be great
edit:
console output: 2020-01-23 17:47:59.470204-0500 Tutorial 31 - Introduction to Sprike Kit[5666:203542] Metal API Validation Enabled 2020-01-23 17:47:59.715838-0500 Tutorial 31 - Introduction to Sprike Kit[5666:203542] SKView: ignoreRenderSyncInLayoutSubviews is NO. Call _renderSynchronouslyForTime without handler 2020-01-23 17:48:11.764763-0500 Tutorial 31 - Introduction to Sprike Kit[5666:203964] XPC connection interrupted 2020-01-23 17:48:11.765810-0500 Tutorial 31 - Introduction to Sprike Kit[5666:203968] [connection] Connection interrupted: will attempt to reconnect 2020-01-23 17:48:11.765887-0500 Tutorial 31 - Introduction to Sprike Kit[5666:205206] [ServicesDaemonManager] interruptionHandler is called. -[FontServicesDaemonManager connection]_block_invoke Message from debugger: Terminated due to signal 15