Set Phaser.World as parent for sprite

I’m trying to impelemt item pick up and drop in my game.
For picking up I’m doind this:

player.addChild(goldenKey);
goldenKey.x = 0;
goldenKey.y = 0;

Question is how to ‘drop’ the item?
When I do

player.removeChild(goldenKey);
goldenKey.reset(goldenKey.realX, goldenKey.realY);

item disappers somewhere.
I think that I have to set Phaser.World as parent again to make it visible.

Hi @microspace
I think it’s becaue of positions, what is realX and realY values actually.

As far as i know, you could just do:

this.world.add(player.goldenKey)
or
game.add.existing(player.goldenKey)

After doing these, you could set to position of goldenKey

2 Likes

Hi @hcakar! This was really really helpful and incredibly fast answer! You are awesome!

1 Like