fading trail effect

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
oscaradalid
Prole
Posts: 16
Joined: Wed May 09, 2018 11:48 am

fading trail effect

Post 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
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

Re: fading trail effect

Post 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.
User avatar
dusoft
Party member
Posts: 654
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: fading trail effect

Post 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.
Attachments
NqmKgk.png
NqmKgk.png (67.42 KiB) Viewed 7198 times
User avatar
knorke
Party member
Posts: 274
Joined: Wed Jul 14, 2010 7:06 pm
Contact:

Re: fading trail effect

Post 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
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: fading trail effect

Post by darkfrei »

:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
dusoft
Party member
Posts: 654
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: fading trail effect

Post by dusoft »

Yeah, that's nice.
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: fading trail effect

Post 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.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 8 guests