Is there a Chipmunk library for movement using forces/impuls

Official forum for the Chipmunk2D Physics Library.
Post Reply
micksabox
Posts: 2
Joined: Sun Jan 17, 2010 3:45 pm
Contact:

Is there a Chipmunk library for movement using forces/impuls

Post by micksabox »

Hello,

I am developing a top-down 2D iPhone game and I need some sort of library or function for Chipmunk or cocos2d iphone that handles movement in 2-dimensional space using forces or impulse.

Note: There is no gravitity force since it is a top down game.
Note: Again, this will be in Objective-C.

So the function would be something like this:

-(void)moveSprite:(AtlasSprite *)sprite ToPoint:(CGPoint) point{

//Function or library that applies the proper physics and/or impulses to AtlasSprite sprite to get to CGPoint point

}
I just want to know if such a library or function exists. Has anybody implemented this or heard/knows of such a library/function? The problem I have is that it is a little hard to understand forces and vectors and impulses, as testing with them has produced inconsistent results. I WILL have to create the above function manually from scratch either way, therefore I was wondering if I could save myself a little time.

Thanks a lot
viblo
Posts: 206
Joined: Tue Aug 21, 2007 3:12 pm
Contact:

Re: Is there a Chipmunk library for movement using forces/impuls

Post by viblo »

cpBodySlew?
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
micksabox
Posts: 2
Joined: Sun Jan 17, 2010 3:45 pm
Contact:

Re: Is there a Chipmunk library for movement using forces/impuls

Post by micksabox »

viblo wrote:cpBodySlew?
Yes, that works! Thanks a lot. One caveat: The sprite does not stop upon reaching its destination point. Any suggestions? (Sorry, I'm still kind of new to chimpunk and game physics in general).

Thanks a TON.
mobilebros
Posts: 90
Joined: Tue Aug 04, 2009 9:53 am
Contact:

Re: Is there a Chipmunk library for movement using forces/impuls

Post by mobilebros »

Of course I will not pass up the opportunity to shamefully promote the chipmunk-spacemanager specifically written to handle chipmunk with cocos2d-iphone, or even obj-c in general. Its here:

http://code.google.com/p/chipmunk-spacemanager/

If you use cpSprite/cpAtlasSprite/cpShapeNode and then set it's integrationDt to match whatever dt you use in your game loop, then it will indeed do a cpBodySlew correctly based on how you set the position....

You say you used cpBodySlew but it keeps moving after the destination? Its because cpBodySlew sets the velocity, if its any distance traveled at all velocity will not be zero; so the only way for it to actually "stop" would be for you to set the velocity to cpvzero.
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests