-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Error stopping a scene: cannot read property 'destroy' of undefined #5520
Comments
I did a little more digging and it seems my original hunch is right. I have something like the following: class MySprite extends Phaser.Physics.Arcade.Sprite {
constructor() {
this.label = this.scene.add.text(10, 20, 'hello');
}
destroy() {
this.label.destroy();
}
} When I trace
Looking at the base GameObject.destroy, you can see that destroying removes the item from the display list, thus naively using |
I am running into the same issue and for the same reason. It is really helpful to be able to let objects manage their own dependencies without needing special logic to handle scene destruction separately. |
any update on this? I've been having this problem and it's like I don't have any |
destroy game objects during shutdown safely #5520
Thanks for opening this issue, and for submitting a PR to fix it. We have merged your PR into the |
Hey guys I got this problem and trace it that maybe my components have problem but related to image that used in components and those images earlier have been destroyed in destroyed components I have been changed
those list item that have been destroyed earlier, |
Hello, i have this problem too, when i try to delete a phaser "container" object. I really dont know how to handle this. My scene is replicated. I am using phaser within an angular comp... |
it's the solution i want to do ... but it's not good ... |
This is already fixed in the master branch. Please make a build from there and use that. |
Version
Description
Shutting down a scene causes an error:
The error in
DisplayList
is here:https://github.com/photonstorm/phaser/blob/master/src/gameobjects/DisplayList.js#L234
I believe the issue is that some of the objects being destroyed are in turn destroying some sub-objects, which would be on
this.list
, thus making the list shorter.This could be fixed like so:
That would be unaffected by changes to the list along the way.
The text was updated successfully, but these errors were encountered: