confetti.script 559 B

1234567891011121314151617181920212223
  1. local function single_shot()
  2. particlefx.play("#particles") -- <1>
  3. end
  4. function init(self)
  5. single_shot()
  6. timer.delay(3, true, single_shot) -- <2>
  7. msg.post(".", "acquire_input_focus")
  8. end
  9. function on_input(self, action_id, action)
  10. if action_id == hash("mouse_button_left") and action.pressed then -- <3>
  11. single_shot()
  12. end
  13. end
  14. --[[
  15. 1. Start playing the particle effect in component "particles" in this game object.
  16. 2. Setup timer to do a single shot of confetti every 3 seconds.
  17. 3. Play the effect when left mouse button (or touch) is pressed.
  18. --]]