Reputation: 3
I have some objects in game and i want to set isEmpty
variable for each of them like this:
var object1.isEmpty;
if (object1.isEmpty == 0) {
object1.alpha=0.5;
}
How can i do this with Phaser?
Upvotes: 0
Views: 503
Reputation: 3385
If your objects are Phaser Sprites, or anything that extends them, then you can use the built-in data
property to store this:
var bob = this.add.sprite(100, 200, 'textureName');
bob.data.isEmpty = true;
// ...
if (bob.data.isEmpty)
{
// do something ...
}
Upvotes: 1
Reputation: 117
PixiJS & Phaser are using JavaScript, you can edit your objects like this:
//set your isEmpty-Variable as an negative boolean:
var object1.isEmpty = false;
For more information please check: http://www.w3schools.com/js/js_variables.asp
Upvotes: 0