Game Development Reference
In-Depth Information
No Ref objects in Box2D
Box2D does not use Ref objects. So, no memory management! Remember to get rid of all
the Box2D objects through delete and not release . If you knew it already... well, you
remember:
HelloWorld::~HelloWorld(){
delete world;
world = nullptr;
delete _debugDraw;
_debugDraw = nullptr;
}
Note
As I mentioned before, C++11 introduces smart pointers, which are memory managed,
meaning you don't have to delete these objects yourself. However, the topic of shared
pointers is beyond the scope of this topic, and using unique pointers in this chapter would
add way too many lines that had nothing to do with Box2D. And although smart pointers
are amazing, their syntax and usage is, well, let's say very "C++ish".
Search WWH ::




Custom Search