In this example we create a confetti fireworks effect. It is usually used on final screens to congratulate the player on successful completion of a level or game.
The particlefx consists of 6 emitters. They are all the same, but with different images and RGB colors.
It has two modifiers:
Changed properties (from default):
In addition, the curves for Life Scale, Life Alpha, Life Rotation properties have been adjusted to make the particles look like real confetti.
The main script confetti.script
spawns the particlefx on startup or when any key is pressed or the mouse button is clicked. It also has a timer that spawns the particlefx in a loop with a 3 second delay.
confetti.script
local function single_shot()
particlefx.play("#particles") -- <1>
end
function init(self)
single_shot()
timer.delay(3, true, single_shot) -- <2>
msg.post(".", "acquire_input_focus")
end
function on_input(self, action_id, action)
if action.pressed then -- <3>
single_shot()
end
end
--[[
1. Start playing the particle effect in component "particles" in this game object.
2. Setup timer to do a single shot of confetti every 3 seconds.
3. Play the effect on any key pressed.
--]]
If you want to play with these examples, you can get the project on Github.
Do you want to see more examples? Why not write a few yourself and submit a pull request? We love contributions.
GITHUB