I have a code that generates a explosion when 2 b2Bodies hit each other, how can I make the explosion? When I want to create a explosion I always get a error named "self was not declared in this scope". Here is my code:
ContactListener::ContactListener(){};
void ContactListener::BeginContact(b2Contact* contact)
{
b2Fixture* fixtureA = contact->GetFixtureA();
CCSprite *actorA = (CCSprite *) fixtureA->GetBody()->GetUserData();
b2Fixture* fixtureB = contact->GetFixtureB();
CCSprite *actorB = (CCSprite *) fixtureB->GetBody()->GetUserData();
// Return world box touch
if(actorA == nil || actorB == nil) return;
if(actorA.tag == rocketTag || actorB.tag == rocketTag) [self createExplosion];
//Error: self was not declared in this scope.
}
Maybe there is another way I can run a function in a contact listener?