Jambutters Posted December 25, 2017 Share Posted December 25, 2017 Currently using Tiled and my maps have multiple layers : Something like: //Floor: let floor = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] //Trees: just pretend it's filled with different values let trees = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] So how I'm going about it is to generate a PIXI.Sprite for every tile and then pushing those into a container, and that container would be the layer: //an array of PIXI.Textures sliced from the spritesheet for tiles let tileSpriteResources = [texture, texture, texture]; let floorLayer = new PIXI.Container(); let trees = new PIXI.Container(); //something like this: function makeLayerSprites(containerLayer,array, width, height){ let W = width; let D = height; let shiftY = 0; array.map(function(item, index){ if(index >= W){ //shifts Y downwards when X is passed with width shiftY++; } if(item === 0){ let tile = new PIXI.Sprite(tileSpriteResources[0]); tile.setTransform(index * 32, shiftY * 32); containerLayer.addChild(tile); } }); } I'm going to have like.. 6+ layers and I was wondering if I should just generate 1 layer, and then have the rest of them be the children of every PIXI.Sprite on the first layer. Or is my approach just fine ? For culling I'd imagine I would have to loop through all 6 containers children and yeah, I'm not sure how this will strike me in performance. Any general advice or recommendations or how you've implemented multi-layered maps in PIXI ? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 25, 2017 Share Posted December 25, 2017 https://github.com/pixijs/pixi-tilemaphttps://github.com/Alan01252/pixi-tilemap-tutorial That thing is used by RpgMaker MV. Also, you should search for all "tilemap" threads here. I wrote many explanations on better algorithms. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.