Group#sort()

sort(key, order)

Sort the children in the group according to a particular key and ordering.

Call this function to sort the group according to a particular key value and order.

For example to depth sort Sprites for Zelda-style game you might call group.sort('y', Phaser.Group.SORT_ASCENDING) at the bottom of your State.update().

Internally this uses a standard JavaScript Array sort, so everything that applies there also applies here, including
alphabetical sorting, mixing strings and numbers, and Unicode sorting. See MDN for more details.

Parameters
Name Type Argument Default Description
key string <optional>
'z'

The name of the property to sort on. Defaults to the objects z-depth value.

order integer <optional>
Phaser.Group.SORT_ASCENDING

Order ascending (SORT_ASCENDING) or descending (SORT_DESCENDING).

Source code: core/Group.js (Line 1855)
doc_phaser
2017-02-14 10:51:50
Comments
Leave a Comment

Please login to continue.