I see someone have already mentioned of using the easier particles system already. but if in case that you have lots of waterfalls (implying tons of particle instances on screen, your game's framerate might drop to a crawl especially if this is on the weaker mobile devices.
If you don't need to optimize, stop reading. But if you do need to optimize, this is another method that uses far fewer instances although also more complicated:
You can have animated Tiles via event sheet using layer switching method:
What you need is to create multiple Tiles with respect to number of frames you have. (ex. waterfall_1, waterfall_2 up to waterfall_n, where n is total number of animation frames you have) Put all of these in an unused layout.
Then, in the layout, create number of layers with respect to total number of waterfall frames you have (ex. "waterfall_layer1", "waterfall_layer2" up to "waterfall_layerX")
Now, create waterfall_1 at where you want these waterfalls to be on layer "waterfall_layer1".
Now, on start of layout event, you check through all waterfall_1 Tiles using For Each loop, and do the following:
- create waterfall_2 tile on layer "waterfall_layer2"
- create waterfall_3 tile on layer "waterfall_layer3"
...
...
(do this up to the last waterfall tile and last layer)
Now, create 2 global variables called "waterfallstep" and "modwaterfallstep" and set them to 0 and create another global variable called "totalnumberofwaterfallframes" and set it to the number of total animating frames you have for your waterfall.
Now, create "every 0.1 sec." event , where u will increment waterfallstep by 1 and set modwaterfallstep using this formula:
modwaterfallstep = waterfallstep % totalnumberofwaterfallframes
Because of the % modulo operator, this formula will only yield increasing number from 0 to number of waterfall frames you have and then the increasing number will be thrown back to 0 thanks to % modulo operator.
Now, after the action above, you use for loop i = 1 to totalnumberofwaterfallframes. In this loop, you do this:
if (i = modwaterfallstep), set layer "waterfall_layer" + i to be visible.
Else set layer "waterfall_layer" + i to be invisible.
This means, in "every 0.1 sec" event, the event sheet will go through all of your waterfall layers and will make the only one unique layer that is equal to modwaterfallstep to be visible, while all other layers are turned invisible.
This will give you the impression of animating tiles. It is a lot more work and hectic, but you can waterfall as long as you like without affecting performance (unlike using particles). All of these waterfall tiles are also not iterated through in every tick (unlike particles as well). Therefore, there won't be much of any performance cost here at all.