Spining object

Official forum for the Chipmunk2D Physics Library.
Post Reply
arny
Posts: 2
Joined: Wed Oct 10, 2012 9:23 pm
Contact:

Spining object

Post by arny »

hello im starting out using chipmunk which is a awesome library. But im having some trouble coming up with how i would go about making a body spin that cant move on the Y axis, the body would be anchor to the bottom of the screen and would spin on the x axis. I have tried cpBodySetForce and applyForce on the y axis, and messing around with gravity values with no luck.
-thanks
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Spining object

Post by slembcke »

You want a groove joint between the body and a static body. It allows a pivot on one of the bodies to move along a grove on the other. You can use that to force it to keep it's y value.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
arny
Posts: 2
Joined: Wed Oct 10, 2012 9:23 pm
Contact:

Re: Spining object

Post by arny »

ok cool so i got it to spin perfectly using this code it will constantly spin. What i see i failed to mention in my first post is that the object is going to spin based off gestures from the user.
-thanks

Code: Select all

    cpBody* staticBody = cpBodyNewStatic();
    cpBodySetPos(staticBody, ccp(0, 10));
    
    
    cpSpaceAddConstraint(space_, cpGrooveJointNew(staticBody, player.body, ccp(0, 10), ccp(0, 0), cpvzero));
Post Reply

Who is online

Users browsing this forum: No registered users and 40 guests