Jump to content
  • Advertisement
Sign in to follow this  
Pufixas

Need help with Box2D, dynamically create new body

This topic is 2531 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, I hope some of you are using Box2D (I use it with SFML/C++) I need little help.

I can't think of any way on how can I dynamically create new b2Body body. I want to create new one then I click the left mouse button... I tried everything, Using b2Body * body = new b2Body[size] doesn't work because it says that b2Body does not have default constructor. I can only use b2Body body[arrSize], but I can't only define fixed amount of bodies, and it still wont work properly.. maybe i'm doing something wrong, after all this is only my 3rd day using Box2D

Please help me. I am reading manual here but I can't find anything...

Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
From the manual, looks like you do this:



b2World *box2Dworld = new b2World(gravity, doSleep);

b2BodyDef bodyDef;

// fill in the byBodyDef definitions

b2Body *box2Dbody = box2Dworld->CreateBody(&bodyDef);


BTW, you should take Box2d Questions to the Box2d forums, you'll get better help there.

Share this post


Link to post
Share on other sites

From the manual, looks like you do this:



b2World *box2Dworld = new b2World(gravity, doSleep);

b2BodyDef bodyDef;

// fill in the byBodyDef definitions

b2Body *box2Dbody = box2Dworld->CreateBody(&bodyDef);


BTW, you should take Box2d Questions to the Box2d forums, you'll get better help there.


OK, thank you very much :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!