Oyed

Game.world.children render issues

3 posts in this topic

After realising Phaser.TilemapLayer is rendered individually in Game.world, I thought a good idea in order to have certain Game objects render above the Sprites was to have them inserted using addChildAt on Game.world so that they'd be rendered before the last Layer in the Tilemap.

All Entities/Players in my Game were already handled by a single Phaser.Group so all I had to do was change how I created this Group:

const group = new Phaser.Group(Game);

Game.world.addChildAt(group, (Game.world.children.length - 2));
this._group = group;

And it works. However, there is an issue.

The Phaser.TilemapLayer that is being rendered over the Phaser.Group containing the Phaser.Sprite objects, it has Anti-aliasing applied to it. For example:

Before:
594676d419ac8_ScreenShot2017-06-18at20_48_22.png.825fb4f3ee337fd7d6b2a5a2a63e265d.png

After:
594676ec4059f_ScreenShot2017-06-18at20_47_59.png.0e290df56531d9302751a8c8131f1a00.png

Is there anything I'm doing wrong? Thanks.

Share this post


Link to post
Share on other sites

I may not fully understand the problem, but tell me if im close. You have a sprite and you want him to appear behind certain layers. For example, a player walking behind a tree. You want him to appear above the grass but behind the tree so there is some level of depth. I went about this in a different manner by doing the following:

 

        //Add Grass layer
        map.createLayer('Background');
		

        //LOAD THE PLAYER
		player = game.add.sprite(800, 400, 'dude');
        game.physics.enable(player, Phaser.Physics.ARCADE);
        player.body.collideWorldBounds = true;
		player.bringToTop();

		// add other layers
		map.createLayer('Foreground');
        map.createLayer('Treetop');

This makes it so my sprite appears on the appropriate layer and has the depth that i desire. I may have missed your point completely though.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.