Dragging a Sprite (Cocos2D) while Chipmunk is simulating
Posted
by itai alter
on Stack Overflow
See other posts from Stack Overflow
or by itai alter
Published on 2010-05-01T13:10:17Z
Indexed on
2010/05/01
13:17 UTC
Read the original article
Hit count: 479
Hello all! I have a simple project built with Cocos2D and Chipmunk. So far it's just a Ball (body, shape & sprite) bouncing on the Ground (a static line segment at the bottom of the screen).
I implemented the ccTouchesBegan/Moved/Ended methods to drag the ball around. I've tried both:
cpBodySlew(ballBody, touchPoint, 1.0/60.0f);
and
ballBody->p = cgPointMake(touchPoint.x,touchPoint.y);
and while the Ball does follow my dragging, it's still being affected by gravity and it tries to go down (which causes velocity problems and others).
Does anyone know of the preferred way to Drag an active Body while the physics simulation is going on? Do I need somehow to stop the simulation and turn it back on afterwards?
Thanks!
© Stack Overflow or respective owner