How do draw a lot of similar animations
Posted: Thu Feb 08, 2018 11:06 am
First I drew every tile in my game with a separate call to draw. That wasn't a very clever way so I used spritebatches. I have the world separated into areas, each having its own spritebatch.
Now I want to draw animations instead of the tiles (grass wiggling in a breeze, water waving in a wave, trees treeing a breeze etc.). For all of these I will have some sequence of frames which I need to draw.
No due to my vast prior experience I think that drawing each one of these animations separately is a bad idea.
I have a few ideas how to achieve this:
1) Have each area now have multiple spritebatches which contain all animations. Say my grass needs 5 frames for its animation, the water needs 3, then I would have to have at least 15 (lowest common multiple of 3 and 5) spritebatches per area s.t. I can draw both animations, and these 15 spritebatches would just contain 3 full grass animations and 5 full water animations.
2) Have each area posses multiple sequences of spritebatches. One which only draws grass, one which only draws water. In the above example I would now have two sequences of spritebatches. One of length 5, only drawing all grass in the area, One of length 3, drawing all water in the area. I think this is nice since it decouples the two animations from each other. On the other hand this will increase the number of drawing calls, but I think this should still be manageable.
Is one of these two ideas the right one? Or would you do it completly differently?
Now I want to draw animations instead of the tiles (grass wiggling in a breeze, water waving in a wave, trees treeing a breeze etc.). For all of these I will have some sequence of frames which I need to draw.
No due to my vast prior experience I think that drawing each one of these animations separately is a bad idea.
I have a few ideas how to achieve this:
1) Have each area now have multiple spritebatches which contain all animations. Say my grass needs 5 frames for its animation, the water needs 3, then I would have to have at least 15 (lowest common multiple of 3 and 5) spritebatches per area s.t. I can draw both animations, and these 15 spritebatches would just contain 3 full grass animations and 5 full water animations.
2) Have each area posses multiple sequences of spritebatches. One which only draws grass, one which only draws water. In the above example I would now have two sequences of spritebatches. One of length 5, only drawing all grass in the area, One of length 3, drawing all water in the area. I think this is nice since it decouples the two animations from each other. On the other hand this will increase the number of drawing calls, but I think this should still be manageable.
Is one of these two ideas the right one? Or would you do it completly differently?