0

Using LH with cocos2d and Box2d

I have a ball (dynamic body) which goes out of the screen.

I would like to destroy and recreate it, placing it back in its initial position.

Without LevelHelper, I would do it via destroyBody and createBody.

How do I do it with LevelHelper?

CloudEagle
  • 65
  • 1
  • 8

2 Answers2

0

you just make copy of the lhsprite object of ball before destroying and later to recreate ball just add copied lhsprite object to your layer.

mahipat
  • 28
  • 1
  • 5
0

Simpler answer would be

LHSprite *sprite ;//(let us assume this is your sprite) CCPoint originalPos = sprite->getPosition();

if(sprite->position is out of screen){ sprite->getBody->setTransform(b2vec2(originalPos.x/PTM_RATIO, originalPos.y/PTM_RATIO),0); }

Simple. Hope this helps :)

Umesh Sharma
  • 388
  • 5
  • 23