Skip to content

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

Closed
@michalfialadev

Description

@michalfialadev

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions