Page 1 of 1

Particle not re-enabling

Posted: Fri Aug 26, 2016 3:53 pm
by vieuxchat
Here is a custom object :

Code: Select all

defineObject{
	name = "particlesThatVanishes_vieuxchat",
	baseObject = "base_floor_decoration",
	components = {
		{
			class = "Particle",
			offset = vec(0.0, 1, 0.0),
			particleSystem = "essence_water",
			enabled = false,
		},
		{
			class = "Timer",
			enabled = false,
			currentLevelOnly = true,
			triggerOnStart = false,
			timerInterval = 4,
			disableSelf = true,
			onActivate = function(self)
				self.go:spawn("wizard_explosion")
				for e in self.go.map:entitiesAt(self.go.x, self.go.y) do
					if e.name == "spawner" then
						e.spawner:activate()
					end
				end
				self.go.timer:disable()
			end
		},
		{
			class = "Controller",
			onActivate = function(self)
				if not self.go.timer:isEnabled() then 
					self.go.particle:enable()
					self.go.particle:fadeOut(self.go.timer:getTimerInterval(0))
					self.go.timer:start() 
				end
			end,
		},
	},
	tags = { "custom_vieuxchat"},
}
The idea is that when activated, it enables the particle system (the water essence) and makes it fade out. When the fading finishes, every spawner on the tile will spawn.
It works... the first time. If i try to activate it again, the timer starts and the spawning is done when it should be done, but the particle system doesn't appear again and, so, don't fade out.

Why ?

Re: Particle not re-enabling

Posted: Fri Aug 26, 2016 5:03 pm
by AndakRainor
Have you tried with ParticleComponent:restart() or ParticleComponent:fadeIn(time) or something like that? It seems your particles effect has been stoped the first time with fadeOut and never restarted. Enabling the component is not enough...

Re: Particle not re-enabling

Posted: Fri Aug 26, 2016 5:26 pm
by vieuxchat
I tried with restart, but it didn't work. I didn't thought of fadeIn ! And that made the trick :D
Thank you very much :)

It seems the restart doesn't change the "alpha" channel of the particles. I guess the particles were enabled, but still at 0 in alpha.