AtlasSprites in Openframework ?


is there any way to use atlas sprite in OF for iPhone???
Unfortunately I didn’t find any ofxAtlasSprites… :cry:

not sure this is what you mean, but try:

Ooh, I missed this. Seems more flexible than my own batch renderer.

And yeah, atlas sprite/sprite sheet/sprite atlas/texture atlas are all pretty much interchangeable terms.

Thanks, that is exactly what I wanted.

With ofxSpriteSheetRenderer is it possible to have animations that play across multiple rows?
I have a sprite sheet with 16 frames, 4 rows x 4 columns. When I set the length of the animation to be 16 frames only the first 4 frames from the first row are played.

animations have to be laid out sequentially, left to right, top to bottom. They’ll loop around rows, but only at the actual end of a sprite sheet (I think… is this not how they’re working?)

it seems like whenever it reaches the end of a row it loops back to the beginning of that row, instead of continuing to beginning of the next row.

agh. I’ll look into a fix for that… or… you could fix it and issue a git pull request :smiley:

Zach, I have been meaning to mention this, but it is working out great for me. I havn’t really been pushing it too hard performance wise, but it is awesome.

I’ve had no luck on tracing down what’s keeping the renderer from correctly playing an animation that spans more than one row. anyone else?

momo, could you post your code, maybe many eyes will be able to fix it :slight_smile:

Digging back into this now for a new project. If I use the example code but make an animation that spans more than one row, the second row does not play properly.

As an example, if I use this image: with a totalFrames of 9, it will play the first 8 tiles and then one frame of black. A totalFrames of 16 will play the first 8 and then 8 frames of black.

Heyya, I don’t know that I can answer this question because I have ended up forking zach sprite renderer pretty far out. I am now just handling animation on my side and managing the sprite indexes for any particular frame. I don’t think that the performance hit is that big, because what you are really trying to avoid is switching the texture.

Thanks for the reply, jonbro. I tried using your fork yesterday but couldn’t get the example to run (perhaps because, as you said, it’s changed so much?)

yeah, the example won’t run because my fork doesn’t use indexes. It uses just the pixel positions and sizes for pulling the sprites off the sheet. This is so I can have more tightly packed sprite sheets, and use tools like

Quite truthfully, I am not exactly sure what you need to do to make everything work because I am two layers abstracted from the sprite sheet renderer now. Nearly all of the code that I write is in lua, and uses this class as a translation layer: . I will give it a stab though.

I think the only thing is that the struct needs tex_x, tex_y, tex_w, and tex_h to describe the position of the sprite on the sheet.

Then you can use the functions that take a animation_t pointer as normal, with the exception that the animation code won’t work, so you have to do that yourself.

I think that the addCenteredSprite function doesn’t work, but addCenterRotatedSprite does, so just use that.

Man, there are a ton of caveats to my fork, maybe I should just finish it and make a good example :slight_smile:

Just got the latest version of ofxSpriteSheetRenderer from github and the error discussed above still occurs (i.e. it won’t work if the animation spreads across multiple lines of the spritesheet). Had a go at making some changes, but can’t seem to get it to work.

Is there an alternative addon to achieve a similar effect, or is there an alternative animation method completely that could be more efficient?

Any help would be greatly appreciated,