Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderlin committed Nov 21, 2013
1 parent c09ea87 commit d7b9c5e
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,35 @@ This is a simple wrapper for box2d using Openframeworks. The examples below are
Thanks,
Todd

-- Updated with changes and bug fixes from Pull Requests
Contributors: danomatika, jefftimesten, Danoli3 and Julapy
-Danoli3
Instructions
------------
When making a vector of objects you need to be careful. You either need to make a vector of pointers of use the `ofPtr` object.

Everytime you push into the vector `circles` the object is destroyed and the created.
This causing issues for the `b2dBody body` object owned by box2d.

***Incorrect way to store objects.***
```
vector <ofxBox2dCircle> circles;
ofxBox2dCircle circle;
circles.push_back(circle);
```

***Here is the how to create a vector of box2d objects.***
```
// in your header files
vector <ofPtr<ofxBox2dCircle> > circles;
// now add a circle to the vector
ofPtr<ofxBox2dCircle> circle = ofPtr<ofxBox2dCircle>(new ofxBox2dCircle);
// to grab the pointer you use the get() function of ofPtr (std::shared_ptr)
circle.get()->setPhysics(3.0, 0.53, 0.1);
circle.get()->setup(box2d.getWorld(), 100, 100, 10);
circles.push_back(circle);
```

Installation
------------
Expand Down

0 comments on commit d7b9c5e

Please sign in to comment.