Get a grip on bodies of an imported b2world
Posted: Tue Apr 14, 2015 10:47 am
Hi,
it's super simple to import a RUBE-json with b2djson.readFromString. But since i use some of the bodies as player characters, i want to hold pointers to the specific bodies to get their position.
The Box2D manual says: "You usually keep pointers to all the bodies you create." With readFromString (or readFromFile) this is impossible.
I tried to store the b2djson as class member instead and use getBodiesByName, then get the one i need. That seems a) rather complicated and b) do i run in segfaults.
Long story short: How do i get permanently valid pointers on b2bodies that i can use to get their position?
C++, Cocos2d-x 3, Android, btw.
it's super simple to import a RUBE-json with b2djson.readFromString. But since i use some of the bodies as player characters, i want to hold pointers to the specific bodies to get their position.
The Box2D manual says: "You usually keep pointers to all the bodies you create." With readFromString (or readFromFile) this is impossible.
I tried to store the b2djson as class member instead and use getBodiesByName, then get the one i need. That seems a) rather complicated and b) do i run in segfaults.
Long story short: How do i get permanently valid pointers on b2bodies that i can use to get their position?
C++, Cocos2d-x 3, Android, btw.