object:destroyParticles()

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

Overview

This function is used to remove all particles within a region. It will return a number indicating how many particles were destroyed.

Syntax

ParticleSystem:destroyParticles( params )
params (required)

Table. A table that specifies the region of particles to destroy — see the next section for valid entries.

Parameter Reference

x (optional)

Number. The x position of the destruction region, in content space.

y (optional)

Number. The y position of the destruction region, in content space.

angle (optional)

Number. The starting angle (rotation) of the destruction region.

Rectangular Region

halfWidth (optional)

Number. Half the width of the desired rectangular destruction region.

halfHeight (optional)

Number. Half the height of the desired rectangular destruction region.

Circular Region

radius (optional)

Number. Radius of the desired circular destruction region.

Arbitrary Shape

shape (optional)

Array. Array of up to eight x and y coordinates to generate an arbitrary convex destruction region.

Example

local number_of_particles_destroyed = ParticleSystem:destroyParticles(
    {
        x = 123,
        y = 456,
        angle = 45,
        halfWidth = 16,
        halfHeight = 16
    }
)