Phaser API Documentation

  Version: 
Filter

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:
  • *
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
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
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
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
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.<*>
Since: 3.0.0
Focus
Focus
isActive(item)
Focus
Focus

Description:

Checks the given item to see if it is already active within this Process Queue.

Parameters:

name type description
item *

The item to check.

Returns:
Description:

true if the item is active, otherwise false.

Type:
  • boolean
Since: 3.60.0
Focus
Focus
isDestroying(item)
Focus
Focus

Description:

Checks the given item to see if it is already pending destruction from this Process Queue.

Parameters:

name type description
item *

The item to check.

Returns:
Description:

true if the item is pending destruction, otherwise false.

Type:
  • boolean
Since: 3.60.0
Focus
Focus
isPending(item)
Focus
Focus

Description:

Checks the given item to see if it is already pending addition to this Process Queue.

Parameters:

name type description
item *

The item to check.

Returns:
Description:

true if the item is pending insertion, otherwise false.

Type:
  • boolean
Since: 3.60.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
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.<function()>
Inherited from: Phaser.Events.EventEmitter#listeners
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
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
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
Since: 3.0.0
Focus
Focus
remove(item)
Focus
Focus

Description:

Removes an item from the Process Queue.

The item is added to the 'destroy' list and is 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:
  • *
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.

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
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
Since: 3.0.0
Focus
Focus
shutdown()
Focus
Focus

Description:

Removes all listeners.

Inherited from: Phaser.Events.EventEmitter#shutdown
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.<*>
Since: 3.0.0
Focus
Focus