Skip to main content

ParticleSystem

Description:

  A ParticleSystem can be used to create particle effects like fire or smoke.

type

Type: Function.

Description:

  Gets the type of the object as a string.

Signature:

type: function(self: ParticleSystem): string

Returns:

Return TypeDescription
stringThe type as a string.

Of

Type: Function.

Description:

  Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true.

Signature:

typeOf: function(self: ParticleSystem, type_name: string): boolean

Parameters:

ParameterTypeDescription
type_namestringThe name of the type to check for.

Returns:

Return TypeDescription
booleanTrue if the object is of the specified type, false otherwise.

release

Type: Function.

Description:

  Destroys the object's Lua reference. The object will be completely deleted if it's not referenced by any other LÖVE object or thread. This method can be used to immediately clean up resources without waiting for Lua's garbage collector.

Signature:

release: function(self: ParticleSystem): boolean

Returns:

Return TypeDescription
booleanTrue if the object was released by this call, false if it had been previously released.

clone

Type: Function.

Description:

  Creates an identical copy of the ParticleSystem in the stopped state. Overload details:

  1. Cloned ParticleSystem inherit all the set-able state of the original ParticleSystem, but they are initialized stopped.

Signature:

clone: function(self: ParticleSystem): ParticleSystem

Returns:

Return TypeDescription
ParticleSystemThe new identical copy of this ParticleSystem.

setTexture

Type: Function.

Description:

  Sets the texture (Image or Canvas) to be used for the particles.

Signature:

setTexture: function(self: ParticleSystem, texture: Image | Canvas)

Parameters:

ParameterTypeDescription
textureImage or CanvasAn Image or Canvas to use for the particles.

getTexture

Type: Function.

Description:

  Gets the texture (Image or Canvas) used for the particles.

Signature:

getTexture: function(self: ParticleSystem): Image | Canvas

Returns:

Return TypeDescription
Image or CanvasThe Image or Canvas used for the particles.

setBufferSize

Type: Function.

Description:

  Sets the size of the buffer (the max allowed amount of particles in the system).

Signature:

setBufferSize: function(self: ParticleSystem, size: integer)

Parameters:

ParameterTypeDescription
sizeintegerThe buffer size.

getBufferSize

Type: Function.

Description:

  Gets the maximum number of particles the ParticleSystem can have at once.

Signature:

getBufferSize: function(self: ParticleSystem): integer

Returns:

Return TypeDescription
integerThe maximum number of particles.

setInsertMode

Type: Function.

Description:

  Sets the mode to use when the ParticleSystem adds new particles.

Signature:

setInsertMode: function(self: ParticleSystem, mode: string)

Parameters:

ParameterTypeDescription
modestringThe mode to use when the ParticleSystem adds new particles.

getInsertMode

Type: Function.

Description:

  Gets the mode used when the ParticleSystem adds new particles.

Signature:

getInsertMode: function(self: ParticleSystem): string

Returns:

Return TypeDescription
stringThe mode used when the ParticleSystem adds new particles.

setEmissionRate

Type: Function.

Description:

  Sets the amount of particles emitted per second.

Signature:

setEmissionRate: function(self: ParticleSystem, rate: number)

Parameters:

ParameterTypeDescription
ratenumberThe amount of particles per second.

getEmissionRate

Type: Function.

Description:

  Gets the amount of particles emitted per second.

Signature:

getEmissionRate: function(self: ParticleSystem): number

Returns:

Return TypeDescription
numberThe amount of particles per second.

setEmitterLifetime

Type: Function.

Description:

  Sets how long the particle system should emit particles (if -1 then it emits particles forever).

Signature:

setEmitterLifetime: function(self: ParticleSystem, lifetime: number)

Parameters:

ParameterTypeDescription
lifetimenumberThe lifetime of the emitter (in seconds).

getEmitterLifetime

Type: Function.

Description:

  Gets how long the particle system will emit particles (if -1 then it emits particles forever).

Signature:

getEmitterLifetime: function(self: ParticleSystem): number

Returns:

Return TypeDescription
numberThe lifetime of the emitter (in seconds).

setParticleLifetime

Type: Function.

Description:

  Sets the lifetime of the particles.

Signature:

setParticleLifetime: function(self: ParticleSystem, minimum: number, maximum?: number)

Parameters:

ParameterTypeDescription
minimumnumberThe minimum life of the particles (in seconds).
maximumnumberThe maximum life of the particles (in seconds). (Default: min.)

getParticleLifetime

Type: Function.

Description:

  Gets the lifetime of the particles.

Signature:

getParticleLifetime: function(self: ParticleSystem): number, number

Returns:

Return TypeDescription
numberThe minimum life of the particles (in seconds).
numberThe maximum life of the particles (in seconds).

setPosition

Type: Function.

Description:

  Sets the position of the emitter.

Signature:

setPosition: function(self: ParticleSystem, x: number, y: number)

Parameters:

ParameterTypeDescription
xnumberPosition along x-axis.
ynumberPosition along y-axis.

getPosition

Type: Function.

Description:

  Gets the position of the emitter.

Signature:

getPosition: function(self: ParticleSystem): number, number

Returns:

Return TypeDescription
numberPosition along x-axis.
numberPosition along y-axis.

moveTo

Type: Function.

Description:

  Moves the position of the emitter. This results in smoother particle spawning behaviour than if ParticleSystem:setPosition is used every frame.

Signature:

moveTo: function(self: ParticleSystem, x: number, y: number)

Parameters:

ParameterTypeDescription
xnumberPosition along x-axis.
ynumberPosition along y-axis.

setEmissionArea

Type: Function.

Description:

  Sets area-based spawn parameters for the particles. Newly created particles will spawn in an area around the emitter based on the parameters to this function.

Signature:

setEmissionArea: function(self: ParticleSystem, distribution?: string, x?: number, y?: number, angle?: number, relative?: boolean)

Parameters:

ParameterTypeDescription
distributionstringThe type of distribution for new particles.
xnumberThe maximum spawn distance from the emitter along the x-axis for uniform distribution, or the standard deviation along the x-axis for normal distribution.
ynumberThe maximum spawn distance from the emitter along the y-axis for uniform distribution, or the standard deviation along the y-axis for normal distribution.
anglenumberThe angle in radians of the emission area. (Default: 0.)
relativebooleanTrue if newly spawned particles will be oriented relative to the center of the emission area, false otherwise. (Default: false.)

getEmissionArea

Type: Function.

Description:

  Gets the area-based spawn parameters for the particles.

Signature:

getEmissionArea: function(self: ParticleSystem): string, number, number, number, boolean
setAreaSpread: function(self: ParticleSystem, distribution?: string, x?: number, y?: number)
getAreaSpread: function(self: ParticleSystem): string, number, number

Parameters:

ParameterTypeDescription
distributionstringThe distribution parameter.
xnumberThe x parameter.
ynumberThe y parameter.

Returns:

Return TypeDescription
stringThe type of distribution for new particles.
numberThe maximum spawn distance from the emitter along the x-axis for uniform distribution, or the standard deviation along the x-axis for normal distribution.
numberThe maximum spawn distance from the emitter along the y-axis for uniform distribution, or the standard deviation along the y-axis for normal distribution.
numberThe angle in radians of the emission area.
booleanTrue if newly spawned particles will be oriented relative to the center of the emission area, false otherwise.

setDirection

Type: Function.

Description:

  Sets the direction the particles will be emitted in.

Signature:

setDirection: function(self: ParticleSystem, direction: number)

Parameters:

ParameterTypeDescription
directionnumberThe direction of the particles (in radians).

getDirection

Type: Function.

Description:

  Gets the direction of the particle emitter (in radians).

Signature:

getDirection: function(self: ParticleSystem): number

Returns:

Return TypeDescription
numberThe direction of the emitter (radians).

setSpread

Type: Function.

Description:

  Sets the amount of spread for the system.

Signature:

setSpread: function(self: ParticleSystem, spread: number)

Parameters:

ParameterTypeDescription
spreadnumberThe amount of spread (radians).

getSpread

Type: Function.

Description:

  Gets the amount of directional spread of the particle emitter (in radians).

Signature:

getSpread: function(self: ParticleSystem): number

Returns:

Return TypeDescription
numberThe spread of the emitter (radians).

setSpeed

Type: Function.

Description:

  Sets the speed of the particles.

Signature:

setSpeed: function(self: ParticleSystem, minimum: number, maximum?: number)

Parameters:

ParameterTypeDescription
minimumnumberThe minimum linear speed of the particles.
maximumnumberThe maximum linear speed of the particles. (Default: min.)

getSpeed

Type: Function.

Description:

  Gets the speed of the particles.

Signature:

getSpeed: function(self: ParticleSystem): number, number

Returns:

Return TypeDescription
numberThe minimum linear speed of the particles.
numberThe maximum linear speed of the particles.

setLinearAcceleration

Type: Function.

Description:

  Sets the linear acceleration (acceleration along the x and y axes) for particles. Every particle created will accelerate along the x and y axes between xmin,ymin and xmax,ymax.

Signature:

setLinearAcceleration: function(self: ParticleSystem, xmin: number, ymin: number, xmax?: number, ymax?: number)

Parameters:

ParameterTypeDescription
xminnumberThe minimum acceleration along the x axis.
yminnumberThe minimum acceleration along the y axis.
xmaxnumberThe maximum acceleration along the x axis. (Default: xmin.)
ymaxnumberThe maximum acceleration along the y axis. (Default: ymin.)

getLinearAcceleration

Type: Function.

Description:

  Gets the linear acceleration (acceleration along the x and y axes) for particles. Every particle created will accelerate along the x and y axes between xmin,ymin and xmax,ymax.

Signature:

getLinearAcceleration: function(self: ParticleSystem): number, number, number, number

Returns:

Return TypeDescription
numberThe minimum acceleration along the x axis.
numberThe minimum acceleration along the y axis.
numberThe maximum acceleration along the x axis.
numberThe maximum acceleration along the y axis.

setRadialAcceleration

Type: Function.

Description:

  Set the radial acceleration (away from the emitter).

Signature:

setRadialAcceleration: function(self: ParticleSystem, minimum: number, maximum?: number)

Parameters:

ParameterTypeDescription
minimumnumberThe minimum acceleration.
maximumnumberThe maximum acceleration. (Default: min.)

getRadialAcceleration

Type: Function.

Description:

  Gets the radial acceleration (away from the emitter).

Signature:

getRadialAcceleration: function(self: ParticleSystem): number, number

Returns:

Return TypeDescription
numberThe minimum acceleration.
numberThe maximum acceleration.

setTangentialAcceleration

Type: Function.

Description:

  Sets the tangential acceleration (acceleration perpendicular to the particle's direction).

Signature:

setTangentialAcceleration: function(self: ParticleSystem, minimum: number, maximum?: number)

Parameters:

ParameterTypeDescription
minimumnumberThe minimum acceleration.
maximumnumberThe maximum acceleration. (Default: min.)

getTangentialAcceleration

Type: Function.

Description:

  Gets the tangential acceleration (acceleration perpendicular to the particle's direction).

Signature:

getTangentialAcceleration: function(self: ParticleSystem): number, number

Returns:

Return TypeDescription
numberThe minimum acceleration.
numberThe maximum acceleration.

setLinearDamping

Type: Function.

Description:

  Sets the amount of linear damping (constant deceleration) for particles.

Signature:

setLinearDamping: function(self: ParticleSystem, minimum: number, maximum?: number)

Parameters:

ParameterTypeDescription
minimumnumberThe minimum amount of linear damping applied to particles.
maximumnumberThe maximum amount of linear damping applied to particles. (Default: min.)

getLinearDamping

Type: Function.

Description:

  Gets the amount of linear damping (constant deceleration) for particles.

Signature:

getLinearDamping: function(self: ParticleSystem): number, number

Returns:

Return TypeDescription
numberThe minimum amount of linear damping applied to particles.
numberThe maximum amount of linear damping applied to particles.

setSizes

Type: Function.

Description:

  Sets a series of sizes by which to scale a particle sprite. 1.0 is normal size. The particle system will interpolate between each size evenly over the particle's lifetime. At least one size must be specified. A maximum of eight may be used.

Signature:

setSizes: function(self: ParticleSystem, sizes: number...)

Parameters:

ParameterTypeDescription
sizesnumber...The first size.

getSizes

Type: Function.

Description:

  Gets the series of sizes by which the sprite is scaled. 1.0 is normal size. The particle system will interpolate between each size evenly over the particle's lifetime.

Signature:

getSizes: function(self: ParticleSystem): number...

Returns:

Return TypeDescription
number...The first size.

setSizeVariation

Type: Function.

Description:

  Sets the amount of size variation (0 meaning no variation and 1 meaning full variation between start and end).

Signature:

setSizeVariation: function(self: ParticleSystem, variation: number)

Parameters:

ParameterTypeDescription
variationnumberThe amount of variation (0 meaning no variation and 1 meaning full variation between start and end).

getSizeVariation

Type: Function.

Description:

  Gets the amount of size variation (0 meaning no variation and 1 meaning full variation between start and end).

Signature:

getSizeVariation: function(self: ParticleSystem): number

Returns:

Return TypeDescription
numberThe amount of variation (0 meaning no variation and 1 meaning full variation between start and end).

setRotation

Type: Function.

Description:

  Sets the rotation of the image upon particle creation (in radians).

Signature:

setRotation: function(self: ParticleSystem, minimum: number, maximum?: number)

Parameters:

ParameterTypeDescription
minimumnumberThe minimum initial angle (radians).
maximumnumberThe maximum initial angle (radians). (Default: min.)

getRotation

Type: Function.

Description:

  Gets the rotation of the image upon particle creation (in radians).

Signature:

getRotation: function(self: ParticleSystem): number, number

Returns:

Return TypeDescription
numberThe minimum initial angle (radians).
numberThe maximum initial angle (radians).

setSpin

Type: Function.

Description:

  Sets the spin of the sprite.

Signature:

setSpin: function(self: ParticleSystem, start: number, finish?: number)

Parameters:

ParameterTypeDescription
startnumberThe minimum spin (radians per second).
finishnumberThe maximum spin (radians per second). (Default: min.)

getSpin

Type: Function.

Description:

  Gets the spin of the sprite.

Signature:

getSpin: function(self: ParticleSystem): number, number

Returns:

Return TypeDescription
numberThe minimum spin (radians per second).
numberThe maximum spin (radians per second).

setSpinVariation

Type: Function.

Description:

  Sets the amount of spin variation (0 meaning no variation and 1 meaning full variation between start and end).

Signature:

setSpinVariation: function(self: ParticleSystem, variation: number)

Parameters:

ParameterTypeDescription
variationnumberThe amount of variation (0 meaning no variation and 1 meaning full variation between start and end).

getSpinVariation

Type: Function.

Description:

  Gets the amount of spin variation (0 meaning no variation and 1 meaning full variation between start and end).

Signature:

getSpinVariation: function(self: ParticleSystem): number

Returns:

Return TypeDescription
numberThe amount of variation (0 meaning no variation and 1 meaning full variation between start and end).

setOffset

Type: Function.

Description:

  Set the offset position which the particle sprite is rotated around. If this function is not used, the particles rotate around their center.

Signature:

setOffset: function(self: ParticleSystem, x: number, y: number)

Parameters:

ParameterTypeDescription
xnumberThe x coordinate of the rotation offset.
ynumberThe y coordinate of the rotation offset.

getOffset

Type: Function.

Description:

  Gets the particle image's draw offset.

Signature:

getOffset: function(self: ParticleSystem): number, number

Returns:

Return TypeDescription
numberThe x coordinate of the particle image's draw offset.
numberThe y coordinate of the particle image's draw offset.

setColors

Type: Function.

Description:

  Sets a series of colors to apply to the particle sprite. The particle system will interpolate between each color evenly over the particle's lifetime. Arguments can be passed in groups of four, representing the components of the desired RGBA value, or as tables of RGBA component values, with a default alpha value of 1 if only three values are given. At least one color must be specified. A maximum of eight may be used. In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.

Signature:

setColors: function(self: ParticleSystem, colors: any...)

Parameters:

ParameterTypeDescription
colorsany...First color, a numerical indexed table with the red, green, blue and alpha values as numbers (0-1). The alpha is optional and defaults to 1 if it is left out.

getColors

Type: Function.

Description:

  Gets the series of colors applied to the particle sprite. In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.

Signature:

getColors: function(self: ParticleSystem): {number}...

Returns:

Return TypeDescription
{number}...First color, red component (0-1).

setQuads

Type: Function.

Description:

  Sets a series of Quads to use for the particle sprites. Particles will choose a Quad from the list based on the particle's current lifetime, allowing for the use of animated sprite sheets with ParticleSystems.

Signature:

setQuads: function(self: ParticleSystem, quads: any...)

Parameters:

ParameterTypeDescription
quadsany...A table containing the Quads to use.

getQuads

Type: Function.

Description:

  Gets the series of Quads used for the particle sprites.

Signature:

getQuads: function(self: ParticleSystem): {Quad}

Returns:

Return TypeDescription
{Quad}A table containing the Quads used.

setRelativeRotation

Type: Function.

Description:

  Sets whether particle angles and rotations are relative to their velocities. If enabled, particles are aligned to the angle of their velocities and rotate relative to that angle.

Signature:

setRelativeRotation: function(self: ParticleSystem, enabled: boolean)

Parameters:

ParameterTypeDescription
enabledbooleanTrue to enable relative particle rotation, false to disable it.

hasRelativeRotation

Type: Function.

Description:

  Gets whether particle angles and rotations are relative to their velocities. If enabled, particles are aligned to the angle of their velocities and rotate relative to that angle.

Signature:

hasRelativeRotation: function(self: ParticleSystem): boolean

Returns:

Return TypeDescription
booleanTrue if relative particle rotation is enabled, false if it's disabled.

getCount

Type: Function.

Description:

  Gets the number of particles that are currently in the system.

Signature:

getCount: function(self: ParticleSystem): integer

Returns:

Return TypeDescription
integerThe current number of live particles.

start

Type: Function.

Description:

  Starts the particle emitter.

Signature:

start: function(self: ParticleSystem)

stop

Type: Function.

Description:

  Stops the particle emitter, resetting the lifetime counter.

Signature:

stop: function(self: ParticleSystem)

pause

Type: Function.

Description:

  Pauses the particle emitter.

Signature:

pause: function(self: ParticleSystem)

reset

Type: Function.

Description:

  Resets the particle emitter, removing any existing particles and resetting the lifetime counter.

Signature:

reset: function(self: ParticleSystem)

emit

Type: Function.

Description:

  Emits a burst of particles from the particle emitter.

Signature:

emit: function(self: ParticleSystem, count: integer)

Parameters:

ParameterTypeDescription
countintegerThe amount of particles to emit. The number of emitted particles will be truncated if the particle system's max buffer size is reached.

isActive

Type: Function.

Description:

  Checks whether the particle system is actively emitting particles.

Signature:

isActive: function(self: ParticleSystem): boolean

Returns:

Return TypeDescription
booleanTrue if system is active, false otherwise.

isPaused

Type: Function.

Description:

  Checks whether the particle system is paused.

Signature:

isPaused: function(self: ParticleSystem): boolean

Returns:

Return TypeDescription
booleanTrue if system is paused, false otherwise.

isStopped

Type: Function.

Description:

  Checks whether the particle system is stopped.

Signature:

isStopped: function(self: ParticleSystem): boolean
isEmpty: function(self: ParticleSystem): boolean
isFull: function(self: ParticleSystem): boolean

Returns:

Return TypeDescription
booleanTrue if system is stopped, false otherwise.

update

Type: Function.

Description:

  Updates the particle system; moving, creating and killing particles.

Signature:

update: function(self: ParticleSystem, delta_time: number)

Parameters:

ParameterTypeDescription
delta_timenumberThe time (seconds) since last frame.