Hi everyone,
I am relativley new to all this and i am having trouble with the whole getting chipmunk bodies to follow my sprites thing.
More specifically i am using this piece of code to make my sprites follow the chipmunk controlled bodies.
static void
eachShape(void *ptr, void* unused)
{
cpShape *shape = (cpShape*) ptr;
Sprite *sprite = shape->data;
if( sprite )
{
cpBody *body = shape->body;
[sprite setPosition: cpv( body->p.x, body->p.y)];
[sprite setRotation: (float) CC_RADIANS_TO_DEGREES( -body->a )];
}
}
This works fine for that, but what i also want to do is have some chipmunk bodies following sprites around that are controlled by varous actions using a similar piece of code like this.
static void
eachShape(void *ptr, void* unused)
{
cpShape *shape = (cpShape*) ptr;
Sprite *sprite = shape->data;
if( sprite )
{
cpBody *body = shape->body;
body->p = sprite.position;
[sprite setRotation: (float) CC_RADIANS_TO_DEGREES( -body->a )];
}
}
My problem is i can only seem to have one or the other running in my game layer, as i said i am new to all this and cannot seem to come up with a solution to having both chipmunk and action controlled sprites with bodies that sync.
Any help or advice would be greatly appreciated!