Class: ParticleContainer

PIXI.ParticleContainer

The ParticleContainer class is a really fast version of the Container built solely for speed, so use when you need a lot of sprites or particles.

The tradeoff of the ParticleContainer is that most advanced functionality will not work. ParticleContainer implements the basic object transform (position, scale, rotation) and some advanced functionality like tint (as of v4.5.6).

Other more advanced functionality like masking, children, filters, etc will not work on sprites in this batch.

It's extremely easy to use:

let container = new ParticleContainer();

for (let i = 0; i < 100; ++i)
{
    let sprite = PIXI.Sprite.from("myImage.png");
    container.addChild(sprite);
}

And here you have a hundred sprites that will be rendered at the speed of light.

new PIXI.ParticleContainer (maxSize, properties, batchSize, autoResize)

Name Type Attributes Default Description
maxSize 1500

The maximum number of particles that can be rendered by the container. Affects size of allocated buffers.

properties IParticleProperties <optional>

The properties of children that should be uploaded to the gpu and applied.

properties.vertices boolean <optional>
false

When true, vertices be uploaded and applied. if sprite's scale/anchor/trim/frame/orig is dynamic, please set true.

properties.position boolean <optional>
true

When true, position be uploaded and applied.

properties.rotation boolean <optional>
false

When true, rotation be uploaded and applied.

properties.uvs boolean <optional>
false

When true, uvs be uploaded and applied.

properties.tint boolean <optional>
false

When true, alpha and tint be uploaded and applied.

batchSize number <optional>
16384

Number of particles per batch. If less than maxSize, it uses maxSize instead.

autoResize boolean <optional>
false

If true, container allocates more batches in case there are more than maxSize particles.

Members

autoResize boolean

If true, container allocates more batches in case there are more than maxSize particles.

Default Value:
  • false

baseTexture PIXI.BaseTexture readonly

The texture used to render the children.

blendMode PIXI.BLEND_MODES

The blend mode to be applied to the sprite. Apply a value of PIXI.BLEND_MODES.NORMAL to reset the blend mode.

Default Value:
  • PIXI.BLEND_MODES.NORMAL

roundPixels boolean

If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. Advantages can include sharper image quality (like text) and faster rendering on canvas. The main disadvantage is movement of objects may appear less smooth. Default to true here as performance is usually the priority for particles.

Default Value:
  • true

tint number

The tint applied to the container. This is a hex value. A value of 0xFFFFFF will remove any tint effect. IMPORTANT: This is a WebGL only feature and will be ignored by the canvas renderer.

Default Value:
  • 0xFFFFFF

Methods

destroy (options) void

Destroys the container

Name Type Attributes Default Description
options IDestroyOptions | boolean <optional>

Options parameter. A boolean will act as if all options have been set to that value

options.children boolean <optional>
false

if set to true, all the children will have their destroy method called as well. 'options' will be passed on to those calls.

options.texture boolean <optional>
false

Only used for child Sprites if options.children is set to true Should it destroy the texture of the child sprite

options.baseTexture boolean <optional>
false

Only used for child Sprites if options.children is set to true Should it destroy the base texture of the child sprite

render (renderer) void

Renders the container using the WebGL renderer.

Name Type Description
renderer PIXI.Renderer

The WebGL renderer.

setProperties (properties) void

Sets the private properties array to dynamic / static based on the passed properties object

Name Type Description
properties IParticleProperties

The properties to be uploaded

onChildrenChange (smallestChildIndex) void protected

Set the flag that static data should be updated to true

Name Type Description
smallestChildIndex number

The smallest child index.