Hello everyone!
It’s Friday and time for another teaser from the engine team. This time we’re showing particlefx callbacks which can be used to get information about the different states a particlefx
emitter goes through. This feature will be released with engine version 1.2.88 on Monday.
The supported states are EMITTER_STATE_SLEEPING
, EMITTER_STATE_PRESPAWN
, EMITTER_STATE_SPAWNING
and EMITTER_STATE_POSTSPAWN
.
go.property("sleep", 0)
local points = 100
local radius = 150
local index = 1
local effects = {}
function particle_callback(self, particlefx_url, emitter_id, state)
if (state == particlefx.EMITTER_STATE_POSTSPAWN) then
index = (index) % #effects + 1
particlefx.play(effects[index], particle_callback)
end
end
function init(self)
local step = 2.0 / points
local centerx = sys.get_config("display.width") / 2
local centery = sys.get_config("display.height") / 2
for i = 0, points do
local x = centerx + math.cos(i * step * math.pi) * radius
local y = centery + math.sin(i * step * math.pi) * radius
effects[i] = factory.create("#factory", vmath.vector3(x, y, 0), nil, {})
end
go.animate(nil, "sleep", go.PLAYBACK_ONCE_FORWARD, 1, go.EASING_LINEAR, 1, 10, function()
particlefx.play(effects[index], particle_callback)
end)
end
Regards,
The engine team through Jakob