glass22 Posted January 1, 2014 Share Posted January 1, 2014 How can I bring a sprite to the front or control sprite depths? or do I need to read the sprite everytime? Link to comment Share on other sites More sharing options...
BitlasLT Posted January 1, 2014 Share Posted January 1, 2014 How do you want to use it ?On input?For depths where are example code in phaser examples .With sprites in group. Link to comment Share on other sites More sharing options...
glass22 Posted January 1, 2014 Author Share Posted January 1, 2014 It's a space game where, I'm loading different levels, but keeping original ship sprite, and because of this ship sprite is at the back, when it should be on highest Z axis Link to comment Share on other sites More sharing options...
BitlasLT Posted January 2, 2014 Share Posted January 2, 2014 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 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(index, order)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 More sharing options...
glass22 Posted January 2, 2014 Author Share Posted January 2, 2014 Ok thank you! Link to comment Share on other sites More sharing options...
Recommended Posts