admin管理员组

文章数量:1401796

I'm trying to make a running and jumping game where I want the sprite to be able to do one double jump.

The problem is that when I click the button a second time while the ninja is in the air, it hardly jumps a second time at all. It just moves up a tiny little bit and isn't a proper second jump. Any advice?

The code I'm using to do the jump is:

let jumpUpAction = SKAction.moveBy(x: 0, y: 80, duration: 0.15)
let jumpUpAction2 = SKAction.moveBy(x: 0, y: 20, duration: 0.025)

let jumpDownAction = SKAction.moveBy(x: 0, y: -80, duration: 0.15)
let jumpDownAction2 = SKAction.moveBy(x: 0, y: -20, duration: 0.025)

let jumpSequence = SKAction.sequence([
  jumpUpAction, jumpUpAction2,
  jumpDownAction, jumpDownAction2
])
ninja.run(jumpSequence)

But when I click the button while the ninja is in the air it hardly jumps a second time at all.

本文标签: iosSpritekit Implementing a double jumpStack Overflow