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
Spining object
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Spining object
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/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 2
- Joined: Wed Oct 10, 2012 9:23 pm
- Contact:
Re: Spining object
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
-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));
Who is online
Users browsing this forum: No registered users and 40 guests