objective c - cocos2d-iphone v3 (Chipmunk) : How to move a CCSprite left or right by applying impulse or force? -


I decided to start learning game programming and I chose Cocos 2DV3 as my first 2D game engine . As far as I understand, Cocos2d-iphone v3 comes with squirrels as a physics engine.

I have an object (box) from left to right of the screen with a platform that manages application to create a picture above it in the

Platform and box attached CCPhysicsBody With CCSprite.

I touch the left side of the screen when I push this box to the left and push to the right when I wanted to touch the left side of the screen. (CGFloat: - (void) applyAngularImpulse CCPhyicsBody

 : box should not jump but just left or right push  

Cocos2d seeing v3 document, I found these methods) impulse - (minus) applyForce: (CGPoint) force - (minus) applyForce: (CGPoint) force atLocalPoint: (CGPoint) point - (minus) applyForce: (CGPoint) force atWorldPoint: (CGPoint) point - (minus) applyImpulse: ( CGPoint) impulse - ApplyImpulse (zero): (CGPoint) impulse atLocalPoint: (CGPoint) point - (minus) applyImpulse: (CGPoint) impulse atWorldPoint: (CGPoint) point - (minus) applyTorque: (CGFloat) torque < / Pre>

and apply by using ApplyImpulse Having passed the CGPpoint location, I manage to jump the box a little bit. But my requirement is for my box to move left or right without just jumping.

Can anyone tell me what method should I use? And what should the parameter be for the method?

Thanks in advance for help!

and passing using applyImpulse and touch base CGPoint, I box Let's take a small jump.

This is the problem. applyImpulse , then You need to provide direction impulse as CGPoint parameters to use as the direction of the impulse to touch base Do not want to.

To implement impulse only you need to create a new CGPoint for the impulse direction and the y value should be 0 of this point:

CGPET impulse = CCP (-10.F, 0F);

Then pass this point by method.


Comments