Jump to content

Sprite.data property


FakeWizard
 Share

Recommended Posts

Just wondering , why Phaser won't let me store any data into the Sprie.data property using the Phaser.Group.setAll() method.

this.bunnies = this.game.add.group();
this.bunnies.createMultiple(5, 'bunny');
this.bunnies.setAll('data.test', 5); 

this.bunnies.forEachExists(function(child){
  console.log(child.data)
}, this);

The documentation clearly says that this property is supposed to be used for such purposes.

Quote

data : Object
An empty Object that belongs to this Game Object.
This value isn't ever used internally by Phaser, but may be used by your own code, or
by Phaser Plugins, to store data that needs to be associated with the Game Object,
without polluting the Game Object directly.

Any ideas? I don't want to extend the Sprite object.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...