ofxBox2D and sprites

Hi there,
I need to use sprites. I’m still not sure what I’d use for that but I need to create a bunch of objects, each one displaying a small animation sequence looped from animated GIF or I still don’t know what format.

I’d really like to use Box2D because of physics, but also objects management etc.

Is there a way to use Box2D with ofxSpriteSheetRenderer for instance?
Would there be another way to do that ?

maybe my question doesn’t make sense.
perhaps, I should focus on ofxSpriteSheetRenderer stuff and forget about Box2D

Ohai Julien. :slight_smile:

Regarding the animation, there’s a good example in graphics, imageSequenceExample which loads an array of images and plays it as an animation.

get ofxBox2d from Vanderlins github repo, I did and there’s an example in there called CustomData where you can learn alot from.

I have a own class extending ofxBox2dCircle,

you can get the box2d sim position with getPosition().x and getPosition().y , and also getRotation().

that’s basically all you need to draw it, and have your animation image sequence draw it instead. here’s a code snippet from a test I did with box2d where I draw my box2d object myself instead of the inherit draw function of ofxBox2dCircle.

void uxCircle::draw() {

float radius = getRadius();


ofTranslate(getPosition().x, getPosition().y, 0);

ofSetColor(color.r, color.g, color.b);
ofCircle(0, 0, radius);

ofLine(0, -radius, 0, radius);
ofLine(-radius, 0, radius, 0);

ofDrawBitmapString(“test” ,0 ,0);


ofTranslate(getPosition().x, getPosition().y, 0);

ofDrawBitmapStringHighlight(“high life”, 0, -20);