Search the Community

Showing results for tags 'z-depth'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 3 results

  1. Hi. I'm new to Phaser and would like to ask for some help with sorting Z depth of sprites using a custom Z value. I know the same question have been asked a million times on the forum but in most case the replies are link to examples and tutorials that explains only that we need to add our sprites to a group and use the sort() method to get the sprites Z depth sorted. I understand that, but I'm really would like to use a custom Z values to sort my sprites. What I'm trying to do, after added all my sprites to a group, I loop through all the children in the group and set their Z value manually, after run the sort() method on the group and I was hoping it is going to sort the Z depth but it does not. This is my code: create: function(){ for(var i = 0; i <= 50; i++){ group.children[i].z = 100; } for(var i = 51; i <= 100; i++){ group.children[i].z = 120; } }, update: function(){ group.sort(Phaser.Group.SORT_ASCENDING); } According to the documentation, If my understanding is correct, the sort() method should use the Z value of each children by default to sort the rendering order. But it is not the case. What seems to happening instead, it override the Z values of the children with their index value. For example, as you can see in my code I set the z value of children[5] to be 100, but what the sort() method seem to be doing is replace 100 with the index number which is 5. If I check the value of Z it return 5 and not 100. If I don't run group.sort() it solves the problem, if I check the value it returns 100 as I would expect, but it does not seem to sort the rendering order without running the sort() method on the group. In most game engines I have been using, there was a very simple, straight forward way to get this done. Normally, all need to be done is set the Z-Depth value but it seem to be not that simple in Phaser. Am I missing something? According to the documentation I think my code should work but it doesn't. I would appreciate any help. Thank you.
  2. I tried to change the z by sprite.z. It displays the value as being changed but it doesn't actually move the sprite's depth based on the other sprites. I want a user to hit a button and pop the sprite to the front of the screen. How can I achieve this. Thanks in advance.
  3. Hello I am new in phaser, i tried the following, but not works (i cant change display order)!! 1. variables var group; var player; var player2; 2. function create() group =; player = game.add.sprite(400, 350, 'player'); player2 = game.add.sprite(400, 350, 'player'); game.physics.enable(player, Phaser.Physics.ARCADE); game.physics.enable(player2, Phaser.Physics.ARCADE); player.add(group); player2.add(group); group.sort(); 3. and at function update() section: i change sprite x,y coordinates by mouse, or velocity and then: group.sort('y', Phaser.Group.SORT_ASCENDING); I want to change the display of sprites (bigger y coordinates, more front like in phaser group examples)... but not works! I manually change z depth of sprite: player.z=10; but no change. I have a lot of sprites, how can i change display order, what did i missed? thanks