I have one question. For animation of my object i using this method in Player class:
func animationPlayerMovement(action: Bool) {
for i in 1...3 {
let name = "player \(i)"
playerTextures.append(SKTexture(imageNamed: name))
}
if(action == true){
playerMovement = SKAction.animate(with: playerTextures, timePerFrame: 0.1, resize: true, restore: true)
self.run(SKAction.repeatForever(playerMovement))
}else{
self.removeAllActions()
}
}
And call this method in function touchesBegan(), when i using virtual joystik. Direction of my sprite take from condition in function touchesMoved():
if(velocityX < 0){
player.xScale = -1
}else{
player.xScale = 1
}
But i have a problem, size of my sprite is changed when i started moving, he becomes bigger by width and heigth. If i change resize in SKAction.animate to false, height is normal, but width change to small and normal for all time of animation. Object "player" was created with this parameters:
player.size = CGSize(width: 40, height: 60)
player.xScale = 1
player.yScale = 1
Does anyone know what the problem is?