Я пытаюсь получить анимацию работать в быстры, но я получаю сообщение об ошибке, что говорит: Индекс фатальной ошибки из диапазона вот код, я использую:Xcode 8 стремительные ИОСЫ: фатальным индекс ошибки из диапазона
import SpriteKit
import GameplayKit
class GameScene: SKScene {
var Player = SKSpriteNode()
var TextureAtlas = SKTextureAtlas()
var TextureArray = [SKTexture]()
override func didMove(to view: SKView) {
TextureAtlas = SKTextureAtlas(named: "images")
for i in 1...TextureAtlas.textureNames.count{
var Name = "front_\(i).png"
TextureArray.append(SKTexture(imageNamed: Name))
}
Player = SKSpriteNode(imageNamed: TextureAtlas.textureNames[0] as! String)
Player.size = CGSize(width: 100, height: 150)
Player.position = CGPoint(x: self.size.width, y: self.size.height)
self.addChild(Player)
backgroundColor = (UIColor.cyan())
}
func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
Player.run(SKAction.repeatForever(SKAction.animate(with: TextureArray, timePerFrame: 1.5)))
}
override func update(_ currentTime: CFTimeInterval) {
}
}
В какой строке указан индекс ошибки? – keithbhunter
Player = SKSpriteNode (imageNamed: TextureAtlas.textureNames [0] as! String) кажется проблемой – void00
Выстрел в темноте, но ваши изображения атласа начинаются с 0 или 1? Ссылаясь на эту строку: 'i in 1 ... TextureAtlas.textureNames.count', которая будет' i в 0 ..