I decided to start learning game programming and i chose cocos2d V3 as my first 2d game engine. As far as I understand, cocos2d-iphone v3 comes with chipmunk as the physics engine.
I manage to create a portrait application that has a Platform across left to right of the screen with an object (Box) on top of it.
Platform and Box are CCSprite with an attached CCPhysicsBody.
I wanted to push this box to the left when i touch the right side of the screen and push it to the right when i touch the left side of the screen. The box should not jump but just push left or right.
by looking from cocos2d v3 documentation, i found these methods : CCPhyicsBody
- (void)applyAngularImpulse:(CGFloat)impulse
- (void)applyForce:(CGPoint)force
- (void)applyForce:(CGPoint)force atLocalPoint:(CGPoint)point
- (void)applyForce:(CGPoint)force atWorldPoint:(CGPoint)point
- (void)applyImpulse:(CGPoint)impulse
- (void)applyImpulse:(CGPoint)impulse atLocalPoint:(CGPoint)point
- (void)applyImpulse:(CGPoint)impulse atWorldPoint:(CGPoint)point
- (void)applyTorque:(CGFloat)torque
and by using applyImpulse and passing the touch location CGPoint, i manage to make the box jump a little bit. But my requirement is for my box to just move to the left or right without jumping.
Can someone please explain to me which method should i use? and what should be the parameter for the method?
Thanks in advance for the help!