Skip to content

Classes

PossiblyAxolotl edited this page Mar 22, 2023 · 26 revisions

If a function returns multiple values you can get all of them as variables like this:

local x, y = Particle:getPos() or local x1, y1, x2, y2 = Particle:getBounds()

Arguments in [square brackets] are optional. For example, in setSize(min[, max]) max is optional

update()

Updates and draws that particle system.

Particle, ParticleCircle, ParticlePixel

Particle is the base class for all particle systems. ParticleCircle is a basic particle system type that can draw circles.

clearParticles()

Clears all particles from that particle system.

remove()

Removes the particle system from the internal particle table, prepares it for garbage collection.

getParticles()

Property Default value
particles {}

Returns a table of all particles currently in that system.

create(amount) / add(amount)

Creates the specified amount of particles with the current parameters.

Position

The position of the particle system.

getPos()

Property Default value
x 0
y 0

Returns the particle system's x and y position.

moveTo(x, y)

Moves the particle system to the specified x and y.

moveBy(x, y)

Moves the particle system by the specified x and y.

Size

The size of particles from a particle system.

getSize()

Property Default value
min 1
max 1

Returns the minimum and maximum size particles from that system can be.

setSize(min[, max])

Sets the minimum and maximum size particles from this system will be, or, if only a min is specified the size of all particles from that system.

Spread

The angle at which particles can spread from the system.

getSpread()

Property Default value
min
max 359°

Returns the minimum and maximum angle particles from that system can move towards.

setSpread(min[, max])

Sets the minimum and maximum angle particles from that system can move towards or sets the only angle particles from that system can move towards.

Speed

The speed particles from that system can move at.

getSpeed()

Property Default value
min 1
max 1

Returns the minimum and maximum possible speed of particles from that system.

setSpeed(min[, max])

Sets the minimum and maximum possible speed of particles from that system or sets the speed of all particles from that system.

Thickness

The thickness of the lines drawing a particle.

A value of 0 means the particles will be filled in completely

does not affect ParticlePixels

getThickness()

Property Default value
min 0
max 0

Returns the minimum and maximum thickness of the lines drawing the shapes from that particle system.

setThickness(min[, max])

Sets the minimum and maximum thickness of the lines drawing the shapes from that particle system or sets the thickness of all lines drawing the shapes from that particle system.

Colour

The colour of a particle system's particles.

getColor/getColour()

Property Default value
colour playdate.graphics.kColorBlack

Returns the current colour as an int.

setColor/setColour(colour)

Sets the colour of the particles from that system.

Mode

The particle draw mode of a particle system.

getMode()

Property Default value
mode Particles.modes.DISAPPEAR

Returns the current mode as a value from 0 to 3.

setMode(mode)

Sets the current mode of that particle system to the specified value.

Lifespan

How long a particle will live for

Only used by Particles.modes.DISAPPEAR

getLifespan()

Property Default value
min 1
max 1

Returns the minimum and maximum lifespan particles from that system may last for

setLifespan(min[, max])

Sets the minimum and maximum lifespan of particles from that system or, if only min is specified, the lifespan of all particles from that system.

Decay

How much a particle will decay by per frame.

Only used by Particles.modes.DECAY, does not affect ParticlePixels

getDecay()

Property Default value
decay 1

Returns how much particles decay by every frame.

setDecay(decay)

Sets how much particles decay by every frame.

Bounds

The boundaries for certain particle modes.

Only used by Particles.modes.LOOP & Particles.modes.STAY

getBounds()

Property Default value
x1 0
y1 0
x2 0
y2 0

Returns all 4 values. x1 and y1 for the top left corner, x2 and y2 for the bottom right.

setBounds(x1, y1, x2, y2)

Sets the edges that particles from that system will loop around.

ParticlePoly

ParticlePoly inherits from Particle so all Particle functions also work with ParticlePolys. ParticlePolys are used to draw shapes with a specific amount of points.

Angular

The angular velocity of particles from a particle system.

getAngular()

Property Default value
min 0
max 0

Returns the possible angular velocity of particles spawned by that particle system.

setAngular(min[, max])

Set the minimum and maximum angular velocity for particles from that particle system or, if only a min is specified, the angular velocity of all particles in the system.

Rotation

The starting rotation of the particle system's particles.

getRotation()

Property Default value
min 0
max 359

Returns the possible starting rotations of the particle system's particles.

setRotation(min[, max])

Sets the possible starting rotations of the particle system's particles.

Points

The amount of points making up the particle system's shapes.

getPoints()

Property Default value
min 3
max 3

Returns the amount of points making up the particle system's shapes.

setPoints(min[, max])

Set the minimum and maximum amount of points for particles from that particle system or, if only a min is specified, the amount of points for all particles in the system.

ParticleImage, ParticleImageBasic

ParticleImages and ParticleImageBasics are both used to draw regular images as particles. ParticleImage is capable of rotating images while ParticleImageBasic is more performant. All Particle functions work for ParticleImages, however they are not affected by thickness or colour.

Angular

The angular velocity of particles from a particle system. Does not affect ParticleImageBasics

getAngular()

Property Default value
min 0
max 0

Returns the possible angular velocity of particles spawned by that particle system.

setAngular(min[, max])

Set the minimum and maximum angular velocity for particles from that particle system or, if only a min is specified, the angular velocity of all particles in the system.

Rotation

The starting rotation of the particle system's particles.

getRotation()

Property Default value
min 0
max 359

Returns the possible starting rotations of the particle system's particles.

setRotation(min[, max])

Sets the possible starting rotations of the particle system's particles.

Image

The image for all particles from that system.

getImage()

Property Default Value
image image

Returns the current image for the system's particles.

setImage(image)

Sets the current image for the system's particles. Sets the current imageTable to nil.

ImageTable

Multiple images to randomly be chosen from as a particle's image.

getImageTable()

Property Default Value
table nil

Returns the current imageTable used by the particle system.

setImageTable(table)

Sets the particle system's imageTable to table. Sets the particle system's image to nil.

Particles

modes

All particle modes, set with setMode(Particles.modes.MODENAME).

Property Description Value
DISAPPEAR Particles will move as long as their lifetime is > 0. (Lifespan decreases by .1 evey frame) 0
DECAY Particles will move as long as their size is > 0. (Size decreases by decay every frame) 1
LOOP Particles will not disappear unless clearParticles or clearAll is called. If bounds are given, particles will loop between them. 2
STAY Particles will not disappear unless clearParticles is called, clearAll is called, or, if bounds are given, when they leave them. 3

update()

Updates all particle systems.

clearAll()

Clears all particle systems (does not delete them, only removes their particles).

removeAll()

Removes all particle systems from the internal particle table and prepares them for garbage collection.

Precision

Some values like speed would work with numbers below 1 but because of Lua's math.random function it requires integers. These values are multiplied by the precision value so if you set it to 0.1 then setting the speed to 12 would actually give you a speed of 1.2

getPrecision()

Property Default Value
prec 1

Gets the precision value

setPrecision(prec)

Sets the precision value