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

GameObject duplication when moving GO between Scene and Container. #6091

Closed
michalfialadev opened this issue Apr 27, 2022 · 1 comment
Closed

Comments

@michalfialadev
Copy link

michalfialadev commented Apr 27, 2022

Version

  • Phaser Version: 3.24.1 and 3.55.2 (tested on both)
  • Operating system: Win10
  • Browser: Chrome, Firefox, Edge (any)

Description

Code pasted below produces 2 objects on screen (visually for sure, unsure about memory, however both objects are offset by 400 pixels from their initial position after the execution, which makes me think that its reference-related, not the object being duplicated in memory).

Example Test Code

// create/add image to scene const myImage = this.add.image(0, 0, "myImgTex", "myImgFrame.png"); // now add the same image to container myContainer.add(myImage); // now add the same image back to scene this.add.existing(myImage); myImage.setPosition(400, 0);

Additional Information

  1. Does it affect other GameObjecttypes (sprite/graphics/particles/..)? Untested.
  2. calling myContainer.remove(myImage); does remove the duplicate image from Container visually (not sure about memory, and does it really clear the reference? - idk how to test this properly using browser's profiler) - would this be a reasonable way to hotfix/hack this issue until proper bugfix is implemented?
@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants