This might be a lenghty question so bare with me.
I'm developing a 2D game i Monogame framework and I'm stuck with it comes to handle large sprite sheets with different frame width, height and animation. I want to load a sprite sheet that has different animation.
Like this one
Some frames in this sprite sheet have different width and height, meaning that I can't use a uniform split with spritesheets width / amount of columns because it will not work with all the frames. I have used a tool that gives me cordinates in JSON format like this
{
"@imagePath": "sprites.png",
"SubTexture": [
{
"@name": "spriteframe1.png",
"@x": "862",
"@y": "0",
"@width": "112",
"@height": "120"
},
{
"@name": "spriteframe10.png",
"@x": "0",
"@y": "320",
"@width": "252",
"@height": "156"
}
}
But here I have problem understanding how I should handle these different frames. How can I switch between animation frames and make sure that the animation loops with state of the object?
E.G If the object in this case flies, I want to loop trough the wing animation but how should I handle it so that only the "Fly-frames" are being looped?
At the moment I have all the frames in a list where every element is a frame with its own x,y,width and height metadata.