Merge pull request #1664 from Chasethechicken/layers

Add missing layer properties
This commit is contained in:
David Négrier 2021-12-24 16:10:15 +01:00 committed by GitHub
commit 36ce4f8f29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 164 additions and 1 deletions

View file

@ -81,7 +81,14 @@ export class GameMap {
let depth = -2;
for (const layer of this.flatLayers) {
if (layer.type === "tilelayer") {
this.phaserLayers.push(phaserMap.createLayer(layer.name, terrains, 0, 0).setDepth(depth));
this.phaserLayers.push(
phaserMap
.createLayer(layer.name, terrains, (layer.x || 0) * 32, (layer.y || 0) * 32)
.setDepth(depth)
.setAlpha(layer.opacity)
.setVisible(layer.visible)
.setSize(layer.width, layer.height)
);
}
if (layer.type === "objectgroup" && layer.name === "floorLayer") {
depth = DEPTH_OVERLAY_INDEX;

View file

@ -120,6 +120,14 @@
<a href="#" class="testLink" data-testmap="focusable_zone_map.json" target="_blank">Focusable Zones</a>
</td>
</tr>
<tr>
<td>
<input type="radio" name="test-layer-visibility"> Success <input type="radio" name="test-layer-visibility"> Failure <input type="radio" name="test-layer-visibility" checked> Pending
</td>
<td>
<a href="#" class="testLink" data-testmap="layer-visibility.json" target="_blank">Layer visibility + Layer size and offset</a>
</td>
</tr>
</table>
<h2>Iframe API</h2>
<table class="table">

View file

@ -0,0 +1,148 @@
{ "compressionlevel":-1,
"height":9,
"infinite":false,
"layers":[
{
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
"height":9,
"id":1,
"name":"floor",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":9,
"x":0,
"y":0
},
{
"data":[34, 34, 34, 0, 0, 0, 0, 0, 0, 34, 34, 34, 0, 0, 0, 0, 0, 0, 34, 34, 34, 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],
"height":9,
"id":7,
"name":"invisible",
"opacity":1,
"type":"tilelayer",
"visible":false,
"width":9,
"x":0,
"y":0
},
{
"data":[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, 12, 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],
"height":9,
"id":2,
"name":"start",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":9,
"x":0,
"y":0
},
{
"data":[78, 79, 80, 89, 90, 91, 100, 101, 102],
"height":3,
"id":9,
"name":"smaller-offset",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":3,
"x":3,
"y":3
},
{
"draworder":"topdown",
"id":3,
"name":"floorLayer",
"objects":[
{
"height":113.62434712736,
"id":2,
"name":"",
"rotation":0,
"text":
{
"text":"The striped tiles in the top left corner should be invisible.",
"wrap":true
},
"type":"",
"visible":true,
"width":108.583142912147,
"x":4.76293503917236,
"y":3.18514798446498
},
{
"height":196.249229945092,
"id":3,
"name":"",
"rotation":0,
"text":
{
"text":"The striped tiles in the top right corner should be transparent and appear above the player.",
"wrap":true
},
"type":"",
"visible":true,
"width":148.867058808759,
"x":137.442726119928,
"y":2.49946430962904
},
{
"height":72.9975893933307,
"id":4,
"name":"",
"rotation":0,
"text":
{
"text":"The plant should be here (the center of the map)",
"wrap":true
},
"type":"",
"visible":true,
"width":151.609793508102,
"x":78.3025091653274,
"y":173.920383018616
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
},
{
"data":[0, 0, 0, 0, 0, 0, 34, 34, 34, 0, 0, 0, 0, 0, 0, 34, 34, 34, 0, 0, 0, 0, 0, 0, 34, 34, 34, 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],
"height":9,
"id":8,
"name":"transparent",
"opacity":0.4,
"type":"tilelayer",
"visible":true,
"width":9,
"x":0,
"y":0
}],
"nextlayerid":10,
"nextobjectid":5,
"orientation":"orthogonal",
"renderorder":"right-down",
"tiledversion":"1.7.2",
"tileheight":32,
"tilesets":[
{
"columns":11,
"firstgid":1,
"image":"tileset1.png",
"imageheight":352,
"imagewidth":352,
"margin":0,
"name":"tileset1",
"spacing":0,
"tilecount":121,
"tileheight":32,
"tilewidth":32
}],
"tilewidth":32,
"type":"map",
"version":"1.6",
"width":9
}