Page 1 of 1
Spining object
Posted: Tue Oct 16, 2012 7:09 pm
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
Re: Spining object
Posted: Tue Oct 16, 2012 10:14 pm
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.
Re: Spining object
Posted: Wed Oct 17, 2012 2:06 am
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));