Noob Particle Problems

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
Sketchy
Prole
Posts: 5
Joined: Fri Oct 30, 2009 2:54 pm
Location: Cörnwall, UK

Noob Particle Problems

Post by Sketchy »

Firstly, I just want to say that I'm very new to Löve, so sorry if this is a noobish question.

I'm starting simple, and making a little asteroids clone. I've got the ship movement working nicely, and want to add a kind of exhaust trail using particles.
I want them to be created at the player's position, and then shoot off backwards. Unfortunately, all of the particles always seem to follow the player object, whereas I only want the emitter to.
What am I doing wrong?
Any help much appreciated :)

btw: I looked at the Particles demo, but all the stuff for changing modes makes it too complicated to learn the basics from.

Here's my code (minus the stuff to do with the player object)

Code: Select all

function load()
	-- Load particle sprite.
	particleSprite = love.graphics.newImage( "Particle.png" )
	
	-- Create new particle system.
	particles = love.graphics.newParticleSystem( particleSprite, 1000 )
	particles: setEmissionRate( 30 )
	particles: setLifetime( -1 )
	particles: setParticleLife( 3 )
	end


function draw()
	-- Draw particles at player position.
	love.graphics.draw( particles, player.xPos , player.yPos )	
	end


function update(dt)
	-- Update particle system.
	particles: setDirection( player.angle )
	particles: setPosition( player.xPos, player.yPos )
	particles: setSpeed( 20 )
	particles: update( dt )
	end
User avatar
kalle2990
Party member
Posts: 245
Joined: Sat Sep 12, 2009 1:17 pm
Location: Sweden

Re: Noob Particle Problems

Post by kalle2990 »

As far as I know, the particles:setPosition(x, y) is setting the offset from the drawing position. So drawing the particle system at top left (0, 0) and setting the position to the player position would probably solve the problem. ^^
User avatar
Sketchy
Prole
Posts: 5
Joined: Fri Oct 30, 2009 2:54 pm
Location: Cörnwall, UK

Re: Noob Particle Problems

Post by Sketchy »

Thanks a lot - that worked perfectly :)
Post Reply

Who is online

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