πŸŽ‰ Celebrating 25 Years of GameDev.net! πŸŽ‰

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

BOX2D SFML Day#1 I am trying to synchronize objects

Started by
5 comments, last by fleabay 3Β years, 5Β months ago

Well I installed BOX2D and SFML. Box2 seems really nice but I have problems, there is no much tutorials that can help me say hello to that interesting libary. I tried today write something but I had a problems with synchronize SFML sprite with BOX2 body, and yes I know that in BOX2D we dont use pixels but meters, but I still have no idea.

So I found one pretty good tutorial, but its old and it doesnt work.

https://hub.packtpub.com/playing-physics/​

I stuck in the part: res->SetUserData(shape);, Visual studio says there is no func SetUserData, and also

sf::Shape* shape = static_cast<sf::Shape*>(body->GetUserData()); there is problem with casting, Can someone with more experince tell me how to fix it, or can you recommend me any good tutorials to do it? That one looks pretty good but its old and doesnt work, I want to know how to synchronize that all elements like sprites and box2d bodys to implement it later to my game, that way looked professional but its outdated.

Advertisement

Programmist94sealand said:
Visual studio says there is no func SetUserData

Visual Studio is actually saying that you haven't told it where to find SetUserData function. Any Box2D lib errors after this one maybe related.

Please post the actual errors you get. Paraphrasing errors isn't very helpful.

πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚<←The tone posse, ready for action.

fleabay said:

Programmist94sealand said:
Visual studio says there is no func SetUserData

Visual Studio is actually saying that you haven't told it where to find SetUserData function. Any Box2D lib errors after this one maybe related.

Please post the actual errors you get. Paraphrasing errors isn't very helpful.

This is function that was used in previous version of Box2D about 5 years ago, already has no replacement. I dont know BOX2D so I can't fix that program, but looks like very good base to learn how to mix that 2 libaries together. Here are error messages:

Error (active) E0413 no suitable conversion function from "b2BodyUserData" to "sf::RectangleShape *" exists LibaryTest C:\Users\ABC\source\repos\LibaryTest\LibaryTest\main.cpp 31  
Error (active) E0135 class "b2Body" has no member "SetUserData" LibaryTest C:\Users\ABC\source\repos\LibaryTest\LibaryTest\main.cpp 65  

Programmist94sealand said:
Well I installed BOX2D and SFML.

If you don't know SFML, you should learn that first.

πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚<←The tone posse, ready for action.

fleabay said:

Programmist94sealand said:
Well I installed BOX2D and SFML.

If you don't know SFML, you should learn that first.

I know SFML

@Programmist94sealand

You program doesn't know how to cast between an SFML shape and a Box2d shape. Since I don't know SFML very well, I'm not sure this cast is even possible.

Your class "b2Body" doesn't have a SetUserData member function. It's YOUR class and I don't think using the same name as a Box2D member function is what you want to do.

I'm interested in this subject so I will spend some time with SFML/Box2D sometime today or tomorrow. You can go on Github and search for β€œsfml box2d” and you should get some examples to try. I see one popular from Sonar Systems has several examples. It's possible that his youtube channel has video tutorials to go along but I'm not sure.

πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚<←The tone posse, ready for action.

This topic is closed to new replies.

Advertisement