Non spriter regular png sprite sheet example

I cannot seem to find any examples of animating a sprite using a regular png / jpeg style sprite sheet. It seems that its extremely easy to use a spriter style animation but no information on regular png sprite sheet animation. Can anyone point me to or give an example of using a regular sprite sheet in Urho3D?

Maybe this AnimatedBillboardSet could help you in the right direction.

Also, welcome to the forums! :confetti_ball: :slight_smile:

This seems like its implementing the rendering of the sprite sheet manually? Is that the only way to do it in Urho3D?

Have you seen sample 24? Though I guess that’s what you mean by Spriter animation.

yep they are using a spriter file in that one. I’m looking for just loading one big packed png or jpeg and having Urho3D take sections of that as the animation.

Then I think animated particles are the closest to what you are looking for, that comes with the engine. The animated billboard set was inspired by it.

It’s quite trivial to map frame numbers to a list of UV-coordinates, or pixels for that matter. Having your own approach can also save you unneeded extras and allows for personal and project-specific logic.

Have you guys checked out SpriteSheet2D class? But I don’t think there is any example code.

No, to be honest.

SpriteSheet2D.h
SpriteSheet2D.cpp

There is a function called DefineSprite in SpriteSheet2D which seems like it maps a region to an id. However; it is hard to determine how this would work to create a sprite sheet animation

What seems unclear about its workings?

well for instance you can name a section of the sprite sheet but how do you use that to cycle through images. All i’m saying is that it would be helpful to have an example for something as common as using a plain sprite sheet.

1 Like

OK, what’s happening, is we are declaring a unique name for each spriteframe we define - each frame of sprite animation will have a unique name, and will be stored in the array called spriteMapping_ inside the spritesheet2d container object.
At runtime, we will call GetSprite(name) at some frequency we decide, in order to update some Sprite ui element. It’s not an ideal system in my opinion but I can see what’s going on - SpriteSheet2D is merely a container, you’re meant to use it inside your own sprite controller class. Why it does not expose a method to look up a sprite frame by index? I don’t know, I can only guess its using a Map container, ie, keys are names, values are sprite frame info - I can’t see why we went this way.

1 Like