Stephen Persson Posted May 24, 2015 Share Posted May 24, 2015 I want a sprite always in the front. Setting z to max didn't do it.game.add.sprite(0, 0, "bg"); var front = game.add.sprite(0, 0, "front");front.z = Math.pow(2, 53); game.add.sprite(300, 200, "object1");game.add.sprite(500, 400, "object2");What is needed? Link to comment Share on other sites More sharing options...
XekeDeath Posted May 24, 2015 Share Posted May 24, 2015 Add it last, and it will be on top... If you will be adding other things later that need to be under it, then I would suggest using Phaser.Groups for layering... Create 2 groups, add what you want to stay on top to the second group, and everything else to the first group... This snippet has 3 groups, because I noticed you have a background image in your example... // Groups for drawing layers var back_layer = game.add.group(); var mid_layer = game.add.group(); var front_layer = game.add.group(); // It doesn't matter what order you add things to these groups, the draw order will be back, mid, front (unless you change it...) back_layer.create(0, 0, "bg"); front_layer.create(0, 0, "front"); mid_layer.create(300, 200, "object1"); mid_layer.create(500, 400, "object2"); spiritabsolute and icp 2 Link to comment Share on other sites More sharing options...
Stephen Persson Posted May 24, 2015 Author Share Posted May 24, 2015 That's a more logical approach than setting an higher index.Thank you for your consideration, Xeke. Link to comment Share on other sites More sharing options...
Recommended Posts