How do you make a trail behind a rectangle?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

How do you make a trail behind a rectangle?

Post by Vimm »

I want to make a little trailing effects behind a moving rectangle I have, but I don't know how to do it. I know that I should use LOVEs particle system, but I can't get those to work, partly because the wiki doesn't tell me what parameters the particle functions take, like if I use

Code: Select all

love.graphics.newParticleSystem()
I get an error saying it expects a texture of some sort.
Can anyone help me understand how to use the particle system to make the trail?
Manyrio
Prole
Posts: 29
Joined: Sat Feb 06, 2016 10:12 am

Re: How do you make a trail behind a rectangle?

Post by Manyrio »

Yes it's normal, if you want to create particle with Löve you have to define some thing
on the wiki, there is a little tutorial :
https://love2d.org/wiki/love.graphics.newParticleSystem
function love.load() end
function love.update(dt) end
function love.draw() end
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Re: How do you make a trail behind a rectangle?

Post by Vimm »

Manyrio wrote:Yes it's normal, if you want to create particle with Löve you have to define some thing
on the wiki, there is a little tutorial :
https://love2d.org/wiki/love.graphics.newParticleSystem
what if im using love.graphics.rectangle() and not an img?
Manyrio
Prole
Posts: 29
Joined: Sat Feb 06, 2016 10:12 am

Re: How do you make a trail behind a rectangle?

Post by Manyrio »

use canvas, do a canvas on your rectangle then use it for your particles
function love.load() end
function love.update(dt) end
function love.draw() end
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Re: How do you make a trail behind a rectangle?

Post by Vimm »

Manyrio wrote:use canvas, do a canvas on your rectangle then use it for your particles
ok its kinda working, but..
1) the particles start off screen and im not sure why
2) they kinda spray off in random directions, I want it to trail behind my square no whatever the direction i move it in.

I attached the LOVE
Attachments
particle.love
(1.07 KiB) Downloaded 123 times
User avatar
Sulunia
Party member
Posts: 203
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: How do you make a trail behind a rectangle?

Post by Sulunia »

I never really messed with the particle systems. Usually i just create a table with past values and draw a fading rectangle on these old positions.

But i guess it is more optimized to do it with particles. Not sure what is wrong though.
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Re: How do you make a trail behind a rectangle?

Post by Vimm »

Sulunia wrote:I never really messed with the particle systems. Usually i just create a table with past values and draw a fading rectangle on these old positions.

But i guess it is more optimized to do it with particles. Not sure what is wrong though.
That kinda what i wanted to do, but I couldnt make it work either lol
User avatar
Sulunia
Party member
Posts: 203
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: How do you make a trail behind a rectangle?

Post by Sulunia »

Check the example attached.

Although i'm going to create a nice WARNING here and say this is probably not the best way of doing this, since i believe the particle system is more optimized. However, it works, and i do the same thing in beatfever since i'm lazy.
Attachments
mouseTrail.love
Love 0.10.1 plis
(930 Bytes) Downloaded 231 times
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Re: How do you make a trail behind a rectangle?

Post by Vimm »

Sulunia wrote:Check the example attached.

Although i'm going to create a nice WARNING here and say this is probably not the best way of doing this, since i believe the particle system is more optimized. However, it works, and i do the same thing in beatfever since i'm lazy.
Yeah thats exactly how I wanted to do it, ill have to practice that code haha. Doesnt help that I'm new to lua as well as LOVE ahaha
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests