Page 1 of 1

Noob Particle Problems

Posted: Fri Oct 30, 2009 3:20 pm
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

Re: Noob Particle Problems

Posted: Fri Oct 30, 2009 3:46 pm
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. ^^

Re: Noob Particle Problems

Posted: Fri Oct 30, 2009 5:44 pm
by Sketchy
Thanks a lot - that worked perfectly :)