how load multiple particle effect

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
paul54000
Prole
Posts: 22
Joined: Mon Nov 28, 2016 12:19 am

how load multiple particle effect

Post by paul54000 »

Hi, i want load 2 particle effect at the same time (bulle.png & brique.png) but that don't work, only one effect work (bulle.png), why ?

Code: Select all

function love.load()
	


  local img2 = love.graphics.newImage('brique.png')
  
  psystem = love.graphics.newParticleSystem(img2, 400)
	psystem:setParticleLifetime(1, 10) -- Particles live at least 2s and at most 5s.
	psystem:setLinearAcceleration(10, 200, 3000, 400) -- Randomized movement towards the bottom of the screen.
	psystem:setColors(200, 200, 151, 100, 10, 5, 295, 10) -- Fade to black.
  psystem:getDirection(500,47,10,47)
  psystem:getSizeVariation(1)
  psystem:getAreaSpread(500, 3000)
  psystem:getPosition(50,100)
  
   local img1 = love.graphics.newImage('bulle.png')
  
  psystem = love.graphics.newParticleSystem(img1, 40000)
	psystem:setParticleLifetime(1, 10) -- Particles live at least 2s and at most 5s.
	psystem:setLinearAcceleration(10, 200, 3000, 400) -- Randomized movement towards the bottom of the screen.
	psystem:setColors(200, 200, 151, 100, 10, 5, 295, 10) -- Fade to black.
  psystem:getDirection(500,47,10,47)
  psystem:getSizeVariation(1)
  psystem:getAreaSpread(500, 3000)
  psystem:getPosition(50,100)
  
  

function love.draw()
	-- Draw the particle system at the center of the game window.
	love.graphics.draw(psystem, love.graphics.getWidth() * 0.5, love.graphics.getHeight() * 0.5)
end
 
function love.update(dt)
	psystem:update(dt)
end
 
function love.mousepressed(x, y, button, istouch)
   if button == 1 then -- Versions prior to 0.10.0 use the MouseConstant 'l'
		psystem:emit(125)
    printx = x
    printy = y
	end
end
end
User avatar
Tjakka5
Party member
Posts: 243
Joined: Thu Dec 26, 2013 12:17 pm

Re: how load multiple particle effect

Post by Tjakka5 »

You are defining a particle system with 'brique.png' and storing it in the variable named 'psystem.'
After that you overwrite 'psystem' with a new particle system with 'bulle.png'.

The solution is to give them different variable names.
(Also note you have to update, draw, and emit them both.)
paul54000
Prole
Posts: 22
Joined: Mon Nov 28, 2016 12:19 am

Re: how load multiple particle effect

Post by paul54000 »

thanks, it's work fine now :

Code: Select all

function love.load()
	

  local brique = love.graphics.newImage('brique.png')
  
  psystem = love.graphics.newParticleSystem(brique, 400)
	psystem:setParticleLifetime(1, 10) -- Particles live at least 2s and at most 5s.
	psystem:setLinearAcceleration(10, 200, 3000, 400) -- Randomized movement towards the bottom of the screen.
	psystem:setColors(200, 200, 151, 100, 10, 5, 295, 10) -- Fade to black.
  psystem:getDirection(500,47,10,47)
  psystem:getSizeVariation(1)
  psystem:getAreaSpread(500, 3000)
  psystem:getPosition(50,100)
  
   local bulle = love.graphics.newImage('bulle.png')
  
  psystem1 = love.graphics.newParticleSystem(bulle, 40000)
	psystem1:setParticleLifetime(1, 10) -- Particles live at least 2s and at most 5s.
	psystem1:setLinearAcceleration(10, 200, 3000, 400) -- Randomized movement towards the bottom of the screen.
	psystem1:setColors(200, 200, 151, 100, 10, 5, 295, 10) -- Fade to black.
  psystem1:getDirection(500,47,10,47)
  psystem1:getSizeVariation(1)
  psystem1:getAreaSpread(500, 3000)
  psystem1:getPosition(50,100)
  

function love.draw()
	-- Draw the particle system at the center of the game window.
	love.graphics.draw(psystem, love.graphics.getWidth() * 0.5, love.graphics.getHeight() * 0.5)
  love.graphics.draw(psystem1, love.graphics.getWidth() * 0.5, love.graphics.getHeight() * 0.5)
end
 
function love.update(dt)
	psystem:update(dt)
  psystem1:update(dt)
end
 
function love.mousepressed(x, y, button, istouch)
   if button == 1 then -- Versions prior to 0.10.0 use the MouseConstant 'l'
		psystem:emit(125)
    printx = x
    printy = y
    psystem1:emit(125)
    printx = x
    printy = y
	end
end
end
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 7 guests