I am developing a game where my character jumps from earth to earth. I do and do everything, except for my remaining problem, if you continue to click on the screen, it can continue to jump forever. I want him 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 it jump:
Knight.physicsBody?.velocity = CGVector(dx: 0, dy: 0)
Knight.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 325))
I have it under touchesBegan, and it adds gravity and momentum, which allows him to jump. But I want him to be able to jump once every time he hits the ground. Please help if you can.
Luyer source
share