override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let touch = touches.first
let positionInScene = touch!.location(in: self)
let touchedNode = self.atPoint(positionInScene)
if let name = touchedNode.name {
if name == "jumpbutton" && isReady == true {
isReady = false
let boost = SKAction.applyImpulse(CGVector(dx: 0, dy: 300.0), duration: 0.1)
touchedNode.run(buttonPressAction)
player?.run(boost)
let wait = SKAction.wait(forDuration: 1.2)
run(wait) { [self] in
isReady = true
}
print("jumpbutton")
}我知道这是非常模糊的,但是我的玩家精灵只是随机地开始逐渐滑向右边或左边,没有明显的原因。当我应用如上所示的垂直脉冲时,它尤其流行。任何洞察力或帮助都是值得感谢的。此外,主体类型是边界矩形,因为它似乎比alpha遮罩或边界圆发生得更少。
发布于 2021-03-30 05:02:58
事实证明,我的图片没有被正确裁剪,因此导致我的球员精灵滑落。
https://stackoverflow.com/questions/66836073
复制相似问题