Jump to content

Sprite remove and add to Childs


stwe
 Share

Recommended Posts

suppose, I have a TileMap and a Button which opens a popup Menu by click.

My popup menu is a sprite (game.add.sprite) which holds some sprites (some Ships) as Child:

popup.addChild(shipArray);

My Tilemap is loading by:


map = game.add.tilemap('Map');
map.addTilesetImage('terrain_atlas', 'terrain_atlas');

background = map.createLayer('Background');
background.resizeWorld();

How do I get the sprite from the popup menu on the tilemap? I have tried the following.

 


// Sprite in the popup menu is clicked
function isShipButtonDown(sprite, pointer) {
    popup.removeChild(sprite);
    sprite.x = 912; // example positions
    sprite.y = 1264;
}

But the sprite is then no longer visible.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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