Below code is a simplest way to do that.
-( void ) explodeBomb { b2Vec2 force = b2Vec2( 0.25 , 0.70 ); // give the direction for the force. bombBody->ApplyLinearImpulse(force, bombBodyDef.position); CCSprite *sp = (CCSprite *) bombBody->GetUserData(); sp.opacity = 0 ; // setting the sprite in the body opacity to zero. [self schedule: @selector (destroyBomb) interval: 2 ]; //destroying bombBody after 2 sec. } -( void ) destroyBomb { CCLOG(@ "Destroying Bomb" ); world->DestroyBody(bombBody); } |
I just got a bunch of errors.
Do you need to import something?
what are the errors you got ?
can you explain.