SetDuration

This function specifies how long, in milliseconds, a particle will exist.

Syntax

Parameters

Remarks

For smoother particle animations use the particle animation shader.

Example

duration = 3000

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
camera:Move(0,0,-3)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

--Create an emitter
emitter = Emitter:Create(100)
emitter:SetDuration(duration)

while true do

if window:Closed() or window:KeyHit(Key.Escape) then return false end

Time:Update()
world:Update()
world:Render()

if (window:KeyDown(Key.Up)) then
duration = duration + 1000
emitter:SetDuration(duration)
elseif (window:KeyDown(Key.Down) and duration > 0.0) then
duration = duration - 1000
emitter:SetDuration(duration)
end

context:SetBlendMode(Blend.Alpha)
context:DrawText("Particles will last for: "..(emitter:GetDuration()/1000) .. " seconds." ,2,2)

context:Sync()
end