I know that this might sound pretty simple. I am having a problem with accessing the userdata of a b2Body in one method through the update method. I need to access the userdata property in the update method to set multiple gravities. I am just not getting it. Below is the update method
-(void) update: (ccTime) dt
{
int32 velocityIterations = 8;
int32 positionIterations = 1;
world->Step(dt, velocityIterations, positionIterations);
for (b2Body* b = world->GetBodyList(); b; b = b->GetNext())
{
if (b->GetUserData() != NULL) {
if (b == spriteData) {
b->ApplyForce( b2Vec2(0.0,9.8*b->GetMass()),b->GetWorldCenter()); // here 0.0 is x, 9.8 is y (the gravity)
}
}
}
}
How do I access the userdata property (spriteData) which is in another method. Please Help