Jump to content

Depth/Layer/Z Axis?


glass22
 Share

Recommended Posts

EDIT:But i suggest you  use group for levels .And add level group first.And ship next.So by using group you would avoid need for depth sorting at all.
Like this:
 

levelGroup=gamd.add.group()level1=game.add.sprite(0,0,"ddd");levelGroup.add(level1)ship=game.add.sprite(0,0,"ddd");function newLevel(){level2=game.add.sprite(0,0,"ddd");levelGroup.add(level2);} 

 


Ok from what i understand  .And from phaser documentation .

You have 2 options :

1.Re add ship itself (you shouldn't notice removing and adding ).You can save old ship variables if it has any ,as temp vars and add into new ship   :D so it would be like old ship on highest depth.

2.Keep levels and ship on same  group and than adding , you can sort it with  group.sort();
Keep ship as first  member of that group .
 index should be 0 ,order one of those Phaser.Group.SORT_ASCENDING OR Phaser.Group.SORT_DESCENDING.

sort(indexorder)

And i think its only ways to do it ,curently as from front page  on phaser 1.13 :
 

 

 

* Added Group.sort. You can now sort the Group based on any given numeric property (x, y, health), finally you can do depth-sorting  :)Example created to show.
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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