我有.atlas文件夹播放我的步行动画,但后来我为左边添加了一个步行动画,当你向左右移动时我会这样做,我不明白为什么因为我在这里调用两个不同的纹理数组...
else if location.x > center {
//moving to the right
moveLeft = false;
playerAnimate.run(SKAction.repeat(SKAction.animate(with: textureArray, timePerFrame: 0.15), count: 1))
let move:SKAction = SKAction.moveBy(x: 18, y: 0, duration: 0)
playerAnimate.run(move)
}
else {
//moving to the left
moveLeft = true;
playerAnimate.run(SKAction.repeat(SKAction.animate(with: textureArray2, timePerFrame: 0.15), count: 1))
let move:SKAction = SKAction.moveBy(x: -18, y: 0, duration: 0)
playerAnimate.run(move)
}
var playerAnimate = SKSpriteNode()
var textureAtlas = SKTextureAtlas()
var textureAtlas2 = SKTextureAtlas()
var textureArray = [SKTexture]()
var textureArray2 = [SKTexture]()
override func didMove(to view: SKView) {
intializeGame();
textureAtlas = SKTextureAtlas(named: "walkingAnimation")
textureAtlas2 = SKTextureAtlas(named: "walkingAnimationLeft")
for i in 1...textureAtlas.textureNames.count {
let name = "win_\(i).png"
textureArray.append(SKTexture(imageNamed: name))
}
for j in 1...textureAtlas2.textureNames.count {
let name2 = "win_\(j).png"
textureArray2.append(SKTexture(imageNamed: name2))
}
}