我有一个在Xcode上使用Swift编写的游戏,其中有一个SKShapeNode跳跃。然而,我希望这个跳跃与玩家的触摸相对应。因此,轻触将得到小跳跃,而更大力度的触摸将得到更高的跳跃。如何实现这一点(请注意,我不想要任何3D触摸选项)?
我有一个在Xcode上使用Swift编写的游戏,其中有一个SKShapeNode跳跃。然而,我希望这个跳跃与玩家的触摸相对应。因此,轻触将得到小跳跃,而更大力度的触摸将得到更高的跳跃。如何实现这一点(请注意,我不想要任何3D触摸选项)?
smallJumpAction
和 bigJumpAction
的动作,那么你可以将其分解成更小的部分......
beginJumpAction
立即触发,然后是 smallJumpEndAction
和 bigJumpEndAction
。let beginJumpAction = //move the player upwards slightly
let smallJumpEndAction = //begin to move the player down
let bigJumpEndAction = //move the player up a bit more and then move down
let blockAction = SKAction.run {
if touchStillDown {
player.runAction(bigJumpEndAction)
} else {
player.runActgion(smallJumpEndAction)
}
}
player.runAction(SKAction.sequence([beginJumpAction, blockAction])
无论如何,总有许多方法来解决这个问题 :)