【发布时间】:2017-02-09 15:48:06
【问题描述】:
在移动动作中,Y 值没有变化,我不知道为什么,因为 X 值在变化。 changeY 变量使用正确的 5.0 或 -5.0 值完成其工作,但“玩家”SkSpriteNode 上的 Y 值没有改变。请帮忙。
override func update(_ currentTime: TimeInterval) {
let percent = touchLocation.x / size.width
let newAngle = percent * 180 - 180
print(newAngle)
if playButtonPressed{
var changeY = 0.0
if newAngle >= -180{
changeY = 5.0
}
else{
changeY = -5.0
}
player.zRotation = CGFloat(newAngle) * CGFloat(M_PI) / 180.0
print(changeY)
var move = SKAction.moveBy(x: -(player.position.x+1), y: CGFloat(changeY), duration: 2000.0)
player.run(move)
}
}
【问题讨论】:
标签: swift xcode sprite skaction