object:createGroup()

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

Overview

This function is used to create multiple particles simultaneously by filling a region.

Syntax

ParticleSystem:createGroup( params )
params (required)

Table. A table that specifies the particle group 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 the particle group. 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"
groupFlags (optional)

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

  • "solid"
  • "rigid"
  • "canBeEmpty"
  • "willBeDestroyed"
  • "needsUpdateDepth"
  • "internalMask"
x (optional)

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

y (optional)

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

angle (optional)

Number. The starting angle (rotation) of the generated group.

linearVelocityX (optional)

Number. The x velocity of the generated group.

linearVelocityY (optional)

Number. The y velocity of the generated group.

angularVelocity (optional)

Number. The angular velocity of the generated group.

color (optional)

Table. Table of RGB+A color settings for the particles in the group.

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

Number. The cohesion of a group of particles in the range of 0.0 (least cohesive) to 1.0 (most cohesive). Default value is 1.0.

stride (optional)

Number. The interval of particles in the group.

lifetime (optional)

Number. Lifetime of the generated group, in seconds.

Rectangular Group

halfWidth (optional)

Number. Half the width of the desired rectangular particle group.

halfHeight (optional)

Number. Half the height of the desired rectangular particle group.

Circular Group

radius (optional)

Number. Radius of the desired circular particle group.

Arbitrary Shape

shape (optional)

Array. Array of up to eight x and y coordinates to generate an arbitrary convex shape group.

Outlined Shape

outline (optional)

Table. Shape table returned by graphics.newOutline().

Examples

Rectangular Group
ParticleSystem:createGroup(
    {
        flags = { "water", "colorMixing" },
        x = 0,
        y = 0,
        color = { 0, 0, 1, 1 },
        halfWidth = 64,
        halfHeight = 32
    }
)
Circular Group
ParticleSystem:createGroup(
    {
        flags = "elastic",
        x = 0,
        y = 0,
        color = { 1, 0, 1, 1 },
        radius = 32
    }
)
Arbitrary Shape
ParticleSystem:createGroup(
    {
        flags = { "elastic", "colorMixing" },
        x = 0,
        y = 0,
        color = { 0, 1, 0, 1 },
        shape = { 0,0, 64,64, 0,64 }
    }
)
Outlined Shape
local imageOutline = graphics.newOutline( 2, "outline.png" )

ParticleSystem:createGroup(
    {
        flags = "water",
        x = 0,
        y = 0,
        color = { 1, 1, 0, 1 },
        outline = imageOutline
    }
)