Page 1 of 1
fading trail effect
Posted: Mon Jul 22, 2024 4:42 pm
by oscaradalid
I'm trying to make this "fading trail effect".. I draw a rectangle and in each frame, I create another rectangle in the previous position with a lower opacity. I do so continuously and each time I diminish somewhat the opacity of the "rectangles created children". My question is: is it possible to do it differently without having to create more rectangles?
In other engines it achieved this by deleting the screen with a low opacity, but it did not achieve such an effect in love2d
Re: fading trail effect
Posted: Mon Jul 22, 2024 8:50 pm
by pgimeno
There are several possible ways, but yours is the most general. It will work on any background and without having to worry about anything else. It will work for opacity changes and also for size changes. I'm not sure if the opacity change will allow auto-batching, probably not, but if the number of trails is reasonably low (say, about 100 or so) that won't be a problem.
Re: fading trail effect
Posted: Mon Jul 22, 2024 9:22 pm
by dusoft
I made the similar trail using just pixels in my demo of a retro game:
https://dusoft.itch.io/captain-bradley- ... itius-demo
But you can use any shape. Maybe particles could work as well, not sure.
Re: fading trail effect
Posted: Tue Jul 23, 2024 12:23 am
by knorke
oscaradalid wrote: ↑Mon Jul 22, 2024 4:42 pmIn other engines it achieved this by deleting the screen with a low opacity, but it did not achieve such an effect in love2d
If I understand what you want correctly, then I might have posted a relevant example here:
viewtopic.php?p=259476#p259476
Re: fading trail effect
Posted: Tue Jul 23, 2024 6:34 am
by darkfrei
Re: fading trail effect
Posted: Tue Jul 23, 2024 3:12 pm
by dusoft
Yeah, that's nice.
Re: fading trail effect
Posted: Thu Jul 25, 2024 7:14 am
by togFox
I just have a table with x, y, alpha values. The alpha value is reduced each dt and removed when it is below zero.