Groups/replace.js example is broken
shinho opened this issue · comments
Nelson Alexandre commented
This is broken because Sprite#group returns undefined. This could be fixed by adding the property to the Sprite class, but since I'm new to Phaser don't know why was it changed.
/**
- @name Phaser.Sprite#group
- @Property {string} group - If Sprite is in a group return the group name
*/
Object.defineProperty(Phaser.Sprite.prototype, "group", {
get: function () {
if (parent && parent.type == Phaser.GROUP)
{
return this.parent.name;
}
else
{
return null;
}
}
});
You also need to add the names to the groups after creating them:
left.name = "left";
right.name = "right";
or at game.add.group() time
Richard Davey commented
Good catch. This is now fixed.