I'm developing a game where my character jumps from land to land. I have everything down and done except my remaining problem is if you keep tapping the screen he can keep jumping forever. I want it so he has to hit the ground before he can jump again.
import SpriteKit
import GameplayKit
class GameScene: SKScene, SKPhysicsContactDelegate {
struct PhysicsCatagory {
static let Knight : UInt32 = 0x1 << 1
static let land : UInt32 = 0x1 << 2
}
var Knight = SKSpriteNode()
var land = SKSpriteNode(imageNamed: "CJLand4")
This is my current code that makes him jump:
Knight.physicsBody?.velocity = CGVector(dx: 0, dy: 0)
Knight.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 325))
I have this under touchesBegan and it adds gravity and on impulse it allows him to jump. But I only want him to be able to jump once every time he hits land. Please help if you can.