How do I achieve this effect without repeating a sprite?

0 favourites
  • 7 posts
From the Asset Store
In this template the music plays without looping in your game
  • Hi. So I'm making my very first game and project and I ran into a problem.

    I don't know how can I achieve this "waterfall" effect without duplicating my 16x16 animated sprite in order to achieve the water movement effect. Ideal would be to use a tiledbackground but those can't have frames to swap and create an animation.

    I know by using my logic repeating a sprite like 10 times per animation, would be like a 100 sprites duplicated per layout. I'm sure I will run into problems with that.

    Is there any way to achieve the same effect? I tried the Scroll plugin by Somebody but I don't thin that works here.

    Here's my game and what I mean:

  • Use a particle system? The particle being a section of your sprite, aim it down. Take out any speed randomization and set the cone angle to 0 so it comes down in a single strip.

    https://dl.dropboxusercontent.com/u/729 ... rFall.capx

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • I don't understand the issue. Why not just use an animated sprite?

  • Cuz using animated sprites for waterfall mean the number of objects required for copy and paste could be tremedous depending on how many waterfalls there are in the layout.

    Also, if the waterfall is long, how many waterfall objects do u need for one waterfall?

    If a layout has just a few short waterfalls, then sure, you can just copy paste animated Sprites all over and call it a day. (I did this in my game. )

  • 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.

    Thank you I will try it out whenever I have some time

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)