Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tilemap won't render when stage.displayList is set #14

Closed
bkjohnson opened this issue Jun 17, 2017 · 2 comments
Closed

Tilemap won't render when stage.displayList is set #14

bkjohnson opened this issue Jun 17, 2017 · 2 comments

Comments

@bkjohnson
Copy link

I've been trying to get my tilemap to render underneath all of the sprites but it always comes out on top no matter what z-index I set the DisplayGroup to be. Also, once I set stage.displayList = new PIXI.DisplayList(); the tilemap won't render at all.

Here is a code snippet:

        // Basic pixi-tilemap example from https://github.com/pixijs/pixi-tilemap
        var loader = new PIXI.loaders.Loader();
        loader.add('atlas', 'basic/atlas.json');
        loader.load(function(loader, resources) {
	        //third parameter is "true" ONLY IF YOUR TILES ARE SQUARES
	        var tilemap = new PIXI.tilemap.CompositeRectTileLayer(0, [resources['atlas_image'].texture], true);
                var size = 32;
                // bah, im too lazy, i just want to specify filenames from atlas
                for (var i=0;i<7;i++)
                    for (var j=0;j<7;j++) {
                        tilemap.addFrame("grass.png", i*size, j*size);
                        if (i%2==1 && j%2==1)
                            tilemap.addFrame("tough.png", i*size, j*size);
                    }

            var ground =  new PIXI.DisplayGroup(0, false)
            var groundContainer = new PIXI.Container()
            groundContainer.displayGroup = ground
            groundContainer.addChild(tilemap)
            stage.addChild(groundContainer)
        })

Here I even tried adding a tilemap to a container and then adding the container to the stage but it still either

  • Won't render at all if stage.displayList is set, or
  • Renders on top of everything if stage.displayList is not set

Any idea as to why this is happening? I'm pretty sure I've followed the examples correctly but of course I could be missing something.

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Jun 17, 2017

there's special flag for those kind of containers , its in readme

tilemap.displayFlag = PIXI.DISPLAY_FLAG.MANUAL_CONTAINER;

Also, i recommend new version: https://github.com/pixijs/pixi-display/tree/layers , it has awesome demo: http://pixijs.github.io/examples/#/layers/lighting.js
API differs from old pixi-display.

@bkjohnson
Copy link
Author

Thank you so much, I'm glad this was such an easy fix!! Also thank you for putting so much work into PIXI - as I've been learning I've been seeing your name all over the place giving answers and writing helpful modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants