Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Moving child sprite to stage and back


s6reinan
 Share

Recommended Posts

I'm having problems transferring sprite from another sprite to stage and then back to another sprite.

The scenario is I have two rotating sprites (wheels) and another sprite (player). Initially, the player is added to wheelA as a child. Upon pressing fire, the player is removed from wheelA and its velocity is changed so that it moves away from wheelA. (Player is removed from wheelA so that it ignores wheelA's rotation). The player is also added to the game via game.add.existing(player);  (Since it doesn't render after removing from wheelA). On update, I check if player overlaps with wheelB. On overlap, I disable the physics of  the player and add it as child of wheelB. The result is player is not rendered on the scene although it is a child of wheelB.

Link to comment
Share on other sites

10 hours ago, s6reinan said:

The result is player is not rendered on the scene although it is a child of wheelB.

Check that the player's `parent` is wheelB (and not null).

Check that the player's `position` is what you want (maybe [0, 0]). It may be off screen.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...