Jump to content

Is it possible to sort nested groups?


Secretmapper
 Share

Recommended Posts

Look at this:

sb3h29.jpg

 

The other 'guy' is behind the tower, even if his y is more than the tower.

        var watcher = this.game.add.group();        watcher.x = 30;        watcher.y = 120;        watcher.create(0, 0, 'sheet', 'Watch-red');        watcher.getAt(0).anchor.setTo(0.5, 1);                board.add(watcher);                var towers = this.game.add.group();        var tower = towers.create(0, 0, 'sheet', 'WatchTower');        tower.anchor.setTo(0, 1);        towers.y = 112;                board.add(towers);                console.log(watcher.y, towers.y); //120, 112

then in my update function:

        board.sort(); // also tried,  board.sort('y', Phaser.Group.SORT_DESCENDING); and ASCENDING, both do image above

Why doesn't it work? is it because it is not possible to sort groups themselves?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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