Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . Structs . ProcessQueue

This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . Structs . ProcessQueue

A Process Queue maintains three internal lists.

The pending list is a selection of items which are due to be made 'active' in the next update. The active list is a selection of items which are considered active and should be updated. The destroy list is a selection of items that were active and are awaiting being destroyed in the next update.

When new items are added to a Process Queue they are put in the pending list, rather than being added immediately the active list. Equally, items that are removed are put into the destroy list, rather than being destroyed immediately. This allows the Process Queue to carefully process each item at a specific, fixed time, rather than at the time of the request from the API.

Constructor:

new ProcessQueue()
Since: 3.0.0

Extends


Members

<private> _active: Array.<*>
Focus
Focus

Description:

The active list is a selection of items which are considered active and should be updated.

Type:
Array.<*>
Default: []
Since: 3.0.0
Focus
Focus
<private> _destroy: Array.<*>
Focus
Focus

Description:

The destroy list is a selection of items that were active and are awaiting being destroyed in the next update.

Type:
Array.<*>
Default: []
Since: 3.0.0
Focus
Focus
<private> _pending: Array.<*>
Focus
Focus

Description:

The pending list is a selection of items which are due to be made 'active' in the next update.

Type:
Array.<*>
Default: []
Since: 3.0.0
Focus
Focus
<private> _toProcess: number
Focus
Focus

Description:

The total number of items awaiting processing.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
checkQueue: boolean
Focus
Focus

Description:

If true only unique objects will be allowed in the queue.

Type:
boolean
Since: 3.50.0
Focus
Focus
<readonly> length: number
Focus
Focus

Description:

The number of entries in the active list.

Type:
number
Since: 3.20.0
Focus
Focus

Methods

add(item)
Focus
Focus

Description:

Adds a new item to the Process Queue.

The item is added to the pending list and made active in the next update.

Parameters:

name type description
item *

The item to add to the queue.

Returns:
Description:

The item that was added.

Type:
  • *
Examples:
Since: 3.0.0
Focus
Focus
addListener(event, fn, [context])
Focus
Focus

Description:

Add a listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#addListener
Examples:
Since: 3.0.0
Focus
Focus
destroy()
Focus
Focus

Description:

Immediately destroys this process queue, clearing all of its internal arrays and resetting the process totals.

Overrides: Phaser.Events.EventEmitter#destroy
Examples:
Since: 3.0.0
Focus
Focus
emit(event, [args])
Focus
Focus

Description:

Calls each of the listeners registered for a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

args * <optional>

Additional arguments that will be passed to the event handler.

Returns:
Description:

true if the event had listeners, else false.

Type:
  • boolean
Inherited from: Phaser.Events.EventEmitter#emit
Examples:
Since: 3.0.0
Focus
Focus
eventNames()
Focus
Focus

Description:

Return an array listing the events for which the emitter has registered listeners.

Type:
  • Array.<(string
  • symbol)>
Inherited from: Phaser.Events.EventEmitter#eventNames
Examples:
Since: 3.0.0
Focus
Focus
getActive()
Focus
Focus

Description:

Returns the current list of active items.

This method returns a reference to the active list array, not a copy of it. Therefore, be careful to not modify this array outside of the ProcessQueue.

Returns:
Description:

A list of active items.

Type:
  • Array.<*>
Examples:
Since: 3.0.0
Focus
Focus
listenerCount(event)
Focus
Focus

Description:

Return the number of listeners listening to a given event.

Parameters:

name type description
event string | symbol

The event name.

Returns:
Description:

The number of listeners.

Type:
  • number
Inherited from: Phaser.Events.EventEmitter#listenerCount
Examples:
Since: 3.0.0
Focus
Focus
listeners(event)
Focus
Focus

Description:

Return the listeners registered for a given event.

Parameters:

name type description
event string | symbol

The event name.

Returns:
Description:

The registered listeners.

Type:
  • Array.
Inherited from: Phaser.Events.EventEmitter#listeners
Examples:
Since: 3.0.0
Focus
Focus
off(event, [fn], [context], [once])
Focus
Focus

Description:

Remove the listeners of a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#off
Examples:
Since: 3.0.0
Focus
Focus
on(event, fn, [context])
Focus
Focus

Description:

Add a listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#on
Examples:
Since: 3.0.0
Focus
Focus
once(event, fn, [context])
Focus
Focus

Description:

Add a one-time listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#once
Examples:
Since: 3.0.0
Focus
Focus
remove(item)
Focus
Focus

Description:

Removes an item from the Process Queue.

The item is added to the pending destroy and fully removed in the next update.

Parameters:

name type description
item *

The item to be removed from the queue.

Returns:
Description:

The item that was removed.

Type:
  • *
Examples:
Since: 3.0.0
Focus
Focus
removeAll()
Focus
Focus

Description:

Removes all active items from this Process Queue.

All the items are marked as 'pending destroy' and fully removed in the next update.

Returns:
Description:

This Process Queue object.

Examples:
Since: 3.20.0
Focus
Focus
removeAllListeners([event])
Focus
Focus

Description:

Remove all listeners, or those of the specified event.

Parameters:

name type arguments description
event string | symbol <optional>

The event name.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#removeAllListeners
Examples:
Since: 3.0.0
Focus
Focus
removeListener(event, [fn], [context], [once])
Focus
Focus

Description:

Remove the listeners of a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#removeListener
Examples:
Since: 3.0.0
Focus
Focus
shutdown()
Focus
Focus

Description:

Removes all listeners.

Inherited from: Phaser.Events.EventEmitter#shutdown
Examples:
Since: 3.0.0
Focus
Focus
update()
Focus
Focus

Description:

Update this queue. First it will process any items awaiting destruction, and remove them.

Then it will check to see if there are any items pending insertion, and move them to an active state. Finally, it will return a list of active items for further processing.

Returns:
Description:

A list of active items.

Type:
  • Array.<*>
Examples:
Since: 3.0.0
Focus
Focus