我有一个问题。对于我的对象的动画我在Player类中使用此方法:
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()
}
}
当我使用虚拟joystik时,在函数touchesBegan()中调用此方法。 我的精灵的方向取自函数touchesMoved()中的条件:
if(velocityX < 0){
player.xScale = -1
}else{
player.xScale = 1
}
但我有一个问题,当我开始移动时,我的精灵的大小会改变,他的宽度和高度会变大。 如果我将SKAction.animate中的调整大小更改为false,则高度正常,但宽度会变为小且正常的所有动画时间。使用以下参数创建了对象“播放器”:
player.size = CGSize(width: 40, height: 60)
player.xScale = 1
player.yScale = 1
有谁知道问题是什么?