Repository navigation
Advanced Particle Emission
So far, every emitter made in this tutorial either continuously emitted particles at a steady rate using ParticleRate or was manually emitted by calling :Emit(). Continuous emission works great for most situations, though sometimes you might want more control over your emitter. For example, what if you want a fountain that sputters every few seconds, or a trail that's only visible while something is moving?
Fortunately, Palette has the tools for this.
The Duration field determines how long one cycle lasts for, in frames. The default is 150, which is 5 seconds. Once the cycle ends, what happens next depends on the value of the Looping field:
-
true(default): The emitter immediately starts a new cycle. -
false: The emitter stops continuously emitting particles. You can callPlay()to start it again.
Here is an example of it in action:
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.ParticleRate = 20
emitter.Duration = 90
emitter.Looping = false2026-11-23.15-52-55.mp4
Particle Emitters also have a DestroyOnFinish field. By default, it's set to false but if you set it to true and Looping is false, the emitter will automatically destroy itself once its cycle is finished and all of its particles are gone. This makes it convenient to implement one-time effects since you don't need to manually destroy the emitter yourself.
StartDelay determines how many frames an emitter waits before it starts its first cycle. By default, it's 0 which means there's no delay. This can be useful for synchronizing multiple emitters together:
local room = Game():GetRoom()
local center = room:GetCenterPos()
local colors = {
KColor(1, 0.3, 0.3, 1),
KColor(0.3, 1, 0.3, 1),
KColor(0.3, 0.5, 1, 1)
}
for i = 1, 3 do
local position = center + Vector((i - 2) * 100, 0)
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", position)
emitter.ParticleRate = 5
emitter.StartColor = colors[i]
emitter.StartDelay = (i - 1) * 30
end2026-11-23.16-15-39.mp4
Note
ParticleEmitter:Prewarm() skips the start delay.
Let's cover something actually exciting which addresses the problems mentioned in the intro! Particle Emitters allow you to set up bursts, which spawn a group of particles all at once at a certain point throughout its cycle.
You can modify the emitter's bursts by accessing its Bursts field, which is a table that stores the list of bursts. Each burst is a dictionary that contains the following fields:
-
Time: When the burst happens in the cycle, in frames. For example, a value of15means the burst will happen 15 frames into the cycle. This is required. -
Count(default:1): How many particles are spawned when the burst happens. You can either give it a number or a{ Min, Max }range. -
Interval(default:1): How many frames a burst will wait before repeating. The number of times a burst repeats is determined by theCyclesfield. -
Cycles(default:1): How many times the burst repeats. Setting it to a value other than 1 means the burst happens everyIntervalframes. Setting it to 0 means the burst will keep repeating until the cycle ends. -
Probability(default:1): The chance that the burst triggers. Must be between0and1.
Here's an emitter that spawns 30 particles at the start of every 2-second cycle:
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.ParticleRate = 0
emitter.MaxParticles = 50
emitter.DirectionSpread = 180
emitter.StartSpeed = { Min = 2, Max = 4 }
emitter.Duration = 60
emitter.Bursts = {
{ Time = 0, Count = 30 }
}2026-11-23.16-24-36.mp4
Warning
Don't forget to define Time! Forgetting to define Time in a burst will cause an error. Additionally, if Time is greater than or equal to the emitter's Duration, the burst will never trigger!
RateOverDistance allows for an emitter to spawn particles based on how far it moves. By default, it's set to 0, which disables it. You can set it to a value that corresponds to how many particles spawn for every unit the emitter travels. For example, a value of 0.2 means one particle will spawn when the emitter travels for 5 units.
This is great for implementing trails with the particles spread out. Here's a trail that follows the player, but is only visible while they move:
local player = Isaac.GetPlayer()
local trail = Palette:CreateParticleEmitter("gfx/particle.png", player.Position)
trail.ParticleRate = 0
trail.RateOverDistance = 0.3
trail.StartSpeed = 0
trail.Lifetime = 30
trail.RenderMode = "BehindEntities"
trail.StartScale = Vector(0.2, 0.2)
trail:FollowEntity(player)2026-11-23.16-29-19.mp4
Finally, let's create something exciting! Below is an example of a firework show, where each cycle starts with a big explosion, followed by smaller explosions that have a 50% chance of happening.
local mod = RegisterMod("Palette Test", 1)
local Palette = include("palette_scripts.palette")
Palette:Init(mod)
mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, function()
local position = Game():GetRoom():GetCenterPos()
local fireworks = Palette:CreateParticleEmitter("gfx/particle.png", position)
fireworks.ParticleRate = 0
fireworks.MaxParticles = 250
fireworks.Duration = 90
fireworks.Lifetime = { Min = 45, Max = 70 }
fireworks.StartSpeed = { Min = 3, Max = 7 }
fireworks.DirectionSpread = 180
fireworks.StartScale = {
Min = Vector(0.2, 0.2),
Max = Vector(0.35, 0.35)
}
fireworks.GravityModifier = 0.04
fireworks.LimitVelocityOverLifetime.Enabled = true
fireworks.LimitVelocityOverLifetime.Drag = 0.06
fireworks.ScaleOverLifetime.Enabled = true
fireworks.ScaleOverLifetime.Keys = {
{ Time = 0, Value = Vector(1, 1) },
{ Time = 1, Value = Vector(0.3, 0.3) }
}
fireworks.ColorOverLifetime.Enabled = true
fireworks.ColorOverLifetime.Gradient = {
AlphaKeys = {
{ Time = 0, Value = 1 },
{ Time = 0.6, Value = 1 },
{ Time = 0.75, Value = 0.4 },
{ Time = 0.85, Value = 1 },
{ Time = 1, Value = 0 }
},
ColorKeys = {
{ Time = 0, Value = KColor(1, 1, 0.6, 1) },
{ Time = 0.3, Value = KColor(1, 0.5, 0.2, 1) },
{ Time = 0.6, Value = KColor(1, 0.2, 0.8, 1) },
{ Time = 1, Value = KColor(0.3, 0.5, 1, 1) }
}
}
fireworks.Bursts = {
{ Time = 0, Count = { Min = 80, Max = 110 } },
{ Time = 30, Count = { Min = 15, Max = 25 }, Cycles = 3, Interval = 10, Probability = 0.5 }
}
end)2026-11-23.16-33-49.mp4
- Palette API
- Particle Emitter API
- AlignToVelocity API
- ColorBySpeed API
- ColorOverLifetime API
- ForceOverLifetime API
- InheritVelocity API
- Keyframe API
- LimitVelocityOverLifetime API
- Noise API
- PaletteBurst API
- PaletteGradient API
- PaletteOverLifetime API
- RotationBySpeed API
- ScaleBySpeed API
- Shape API
- SpriteSheet API
- SubEmitterOptions API
- VelocityOverLifetime API