Jump to content

Omg! Noob! Can't sort layers


Recommended Posts

I must be smashed today but I don't seem to be able to sort out these groups of layers:

this.create = function(game){        var fadeLayer = game.add.group();        var gameLayer = game.add.group();        fadeLayer.z = 1000;        gameLayer.z = 1;        game.fader = game.add.graphics(0, 0);        game.fader.beginFill(0xffcc00);        game.fader.drawRect(0, 0, window.innerWidth, window.innerHeight);        game.fader.alpha = 1;        game.fader.endFill();        fadeLayer.add(game.fader);        background = game.add.tileSprite(0, 0, window.innerWidth, window.innerHeight, "menubg");        gameLayer.add(background);        }

The background is ALWAYS on top! HELP!

Link to comment
Share on other sites

Hmm this seems to be a difficult one, but I'm bumping this post because I found something interesting.

I set up a REALLY REALLY simple example exactly as the "official example", here's the code:

window.onload = function() {        var game = new Phaser.Game(            window.innerWidth, window.innerHeight,            Phaser.AUTO, '',            {                preload: preload,                create: create,                         });        function preload() {            game.load.image('ground', 'phaser.png');            game.load.image('ground2', 'tilex.jpg');        }        function create() {            var topLayer = game.add.group();                topLayer.z = 1;            var gameLayer = game.add.group();                gameLayer.z = 5;            var top = new Phaser.Sprite(game, 0, 0, 'ground');                topLayer.add(top);                var bottom = new Phaser.Sprite(game, 120, 120, 'ground2');                gameLayer.add(bottom);        }      }

...but this did not work either!


So I was stumped and headed back over to it:



since it claims to do the same thing I was trying to do even with the EXACT SAME CODE, but mine did not work.

So I tried messing around with the official code and surprise surprise... even switching those "z" (and pressing the rocket button) it DOESN'T WORK!


What I'm expecting it to do is to switch layer order based on the z index, otherwise those zeds have no need to exist.


Edit: after finding this post:



I now understand that those z-indexes are used for other things.


Still it is SO DECEIVING on that example!

Link to comment
Share on other sites


  • Recently Browsing   0 members

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