Particle end event like animation_done? (SOLVED)

You receive this error because you remove particle before it receives all the messages.
I am using the next code for removing particlefx:

go.property("path", msg.url("#particle_fx"))
go.property("need_to_remove", 1)

local function particle_callback(self, particlefx_url, emitter_id, state)
  if state == particlefx.EMITTER_STATE_PRESPAWN then
    self.counter = self.counter + 1 -- count how many emitters start working
  elseif state == particlefx.EMITTER_STATE_SLEEPING then
    self.counter = self.counter - 1 -- when the last emitter is sleeping remove GO
    if self.counter == 0 then
      go.delete(".")
    end
  end
end

function init(self)
  self.counter = 0
  if self.need_to_remove == 1 then
    particlefx.play(self.path, particle_callback)
  else
    particlefx.play(self.path)
  end
end
3 Likes