Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group does not pass reference of game to newly recycled objects #6

Closed
jessefreeman opened this issue Apr 20, 2013 · 1 comment
Closed

Comments

@jessefreeman
Copy link

If you use recycle to create an object when the group is empty it will not correctly supply the passed in ObjectClass a reference to game. I have modified this in my own build to do:

return this.add(new ObjectClass(this._game));

on lines 289 and 317. Since the ObjectClass parameter is not typed nor is the return I am just making the assumption that the simplest primitive a Group can accept is Basic. Is there a use case where you would use group to manage other objects that are not extended from basic?

Here is my use case:

function creatBullet() {
        var bullet:Phaser.Sprite = <Phaser.Sprite>bulletGroup.recycle(Phaser.Sprite);
        bullet.x = player.x + (player.flipped ? 0 : player.width);
        bullet.y = player.y + 25;
        bullet.loadGraphic("entities");
        bullet.flipped = player.flipped;
        bullet.animations.frameName = "bullet-gun.png";
}

You should probably add some more tests for groups.

@photonstorm
Copy link
Collaborator

Fixed in 0.9.3. Groups cannot (or rather, should not) manage anything that doesn't extend Basic at some point. Although technically from a JS point of view you could give it any object so long as it had the same properties as Basic does (not from a TS point though)

mcfarlanedev pushed a commit to mcfarlanedev/phaser that referenced this issue May 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants