object:createParticle()

Type Function
Object ParticleSystem
Library physics.*
Return value none
Revision Release 2022.3683
Keywords createParticle, physics, LiquidFun
See also physics.newParticleSystem()
object:destroyParticles()
object:createGroup()
particleCollision

Overview

This function is used to create a single particle in a ParticleSystem.

Syntax

ParticleSystem:createParticle( params )
params (required)

Table. A table that specifies the particle properties (flags) — see the next section for valid entries.

Important

When implementing particle collisions via the particleCollision event, you must set the "fixtureContactListener" flag for each particle. If this flag is omitted, you will not receive particle collision responses.

Parameter Reference

To learn more about the parameters available for particles, please refer to the LiquidFun Programmer's Guide.

flags (optional)

String or Table. One of the following strings or a table containing a comma-delimited list of these strings.

  • "water"
  • "zombie"
  • "wall"
  • "spring"
  • "elastic"
  • "viscous"
  • "powder"
  • "tensile"
  • "colorMixing"
  • "destructionListener"
  • "barrier"
  • "staticPressure"
  • "reactive"
  • "repulsive"
  • "fixtureContactListener"
  • "fixtureContactFilter"
  • "particleContactFilter"
x (optional)

Number. The starting x position of the generated particles, in content space.

y (optional)

Number. The starting y position of the generated particles, in content space.

velocityX (optional)

Number. The x velocity of the generated particles.

velocityY (optional)

Number. The y velocity of the generated particles.

color (optional)

Table. Table of RGB+A color settings for the generated particles.

color = { 0, 0.3, 1, 1 }
lifetime (optional)

Number. Lifetime of the generated particles, in seconds.

Example

ParticleSystem:createParticle(
    {
        flags = { "water", "colorMixing" },
        x = 0,
        y = 0,
        velocityX = 256,
        velocityY = 480,
        color = { 0, 0, 1, 1 },
        lifetime = 32.0
    }
)