Skip to content

Commit 601c769

Browse files
committed
Game Objects have a new property called state.
1 parent e34d759 commit 601c769

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* The data object being sent to the Dynamic Bitmap Text callback now has a new property `parent`, which is a reference to the Bitmap Text instance that owns the data object (thanks ornyth)
88
* The WebGL Renderer has a new method `clearPipeline`, which will clear down the current pipeline and reset the blend mode, ready for the context to be passed to a 3rd party library.
99
* The WebGL Renderer has a new method `rebindPipeline`, which will rebind the given pipeline instance, reset the blank texture and reset the blend mode. Which is useful for recovering from 3rd party libs that have modified the gl context.
10+
* Game Objects have a new property called `state`. Use this to track the state of a Game Object during its lifetime. For example, it could move from a state of 'moving', to 'attacking', to 'dead'. Phaser itself will never set this property, although plugins are allowed to.
1011

1112
### Updates
1213

src/gameobjects/GameObject.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@ var GameObject = new Class({
5555
*/
5656
this.type = type;
5757

58+
/**
59+
* The current state of this Game Object.
60+
*
61+
* Phaser itself will never modify this value, although plugins may do so.
62+
*
63+
* Use this property to track the state of a Game Object during its lifetime. For example, it could move from
64+
* a state of 'moving', to 'attacking', to 'dead'. The state value should typically be an integer (ideally mapped to a constant
65+
* in your game code), but could also be a string, or any other data-type. It is recommended to keep it light and simple.
66+
* If you need to store complex data about your Game Object, look at using the Data Component instead.
67+
*
68+
* @name Phaser.GameObjects.GameObject#state
69+
* @type {{integer|string}}
70+
* @since 3.16.0
71+
*/
72+
this.state = 0;
73+
5874
/**
5975
* The parent Container of this Game Object, if it has one.
6076
*

0 commit comments

Comments
 (0)