0
votes

How would I make my sprite dino jump? I have a physics world set up

_physicsWorld = [CCPhysicsNode node];
_physicsWorld.gravity = ccp(0, 0);
_physicsWorld.debugDraw = NO;
_physicsWorld.collisionDelegate = self;
[self addChild:_physicsWorld];

I was thinking that I could applyForce to make the sprite jump but that will only shoot it up, this is where i am using the physics world to make the sprite move up

- (void)onJButtonClicked:(id)sender
{
CGPoint force = ccpMult(ccp(0,90), 10); //x=0, y=90, force=600
[dino.physicsBody applyForce:force];
}
1

1 Answers

0
votes

In space no one can jump. Unless they are on a planet that exerts a gravitational force.

_physicsWorld.gravity = ccp(0, -9);

Tweak gravity as needed.