You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First working demo of multiple tileset sources specified in a single Tiled map layer being rendered as separate Batch drawing lists by the webgl renderer.
Phaser.Tilemap now creates internal map layers for each tileset except the first one (which will be handled by the createLayer call from the game). It also stores a reference to each tileset where the new map layers can access it.
Phaser.TilemapLayerGL uses the new tileset reference to ensure the correct base image and tile sizes are used for each new layer.
PIXI.Tilemap: added initialisation of glBatch to null in c'tor.
Phaser.TilemapParser was cleaned up to remove the now unnecessary tilemap parameter and the attempt to create layers while parsing.
Copy file name to clipboardExpand all lines: docs/_phaser_tilemap_GL_progress.txt
+16-2Lines changed: 16 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -144,7 +144,7 @@ Attempted a quick hack to test the new layers approach but got bogged down in th
144
144
Some notes for later:
145
145
- Tilemap creates TilemapLayer objects (Sprites). It keeps no reference to them after adding them to a group (or the world group), the new layer object gets a 'map' reference.
146
146
- Tilemap contains a layers member variable, it contains bespoke objects (see createBlankLayer) with some information about layers in the map data (which do not correspond to TilemapLayer objects at all)
147
-
- TilemapParser parses raw map data into the Tilemap.data member. It creates Tileset objects and populates them for each tile set used in the raw map. It creates Tile objects for each tile in the map data.
147
+
- TilemapParser parses raw map data into a local 'map' variable which is returned to be set as the Tilemap.data member. It creates Tileset objects and populates them for each tile set used in the raw map. It creates Tile objects for each tile in the map data.
148
148
- Tileset contains information about separate tile sources, including the image, the first tile, tile layout in the image. It contains the draw function to render a tile on the canvas.
149
149
- Tilemap.createLayer is called by Examples after the Tilemap has been created and parsed.
150
150
@@ -153,6 +153,20 @@ So, I can't create new TilemapLayer objects in TilemapParser because it will pre
153
153
day seven:
154
154
155
155
Read through the above and took a good look at the code. It's a messy solution in this context.
156
-
A better idea... parse the map as previously, on return to Tilemap create layers for each 'unique' entry in tilesets array.
156
+
A better idea... parse the map as originally, on return to Tilemap create layers for each 'unique' entry in tilesets array.
157
157
This avoids the circular calls to and from tilemap and parse, allows map to have a populated data member after parse, and still creates the required new layers before the example calls createLayer.
158
158
(Check if this process can be added to createLayer?)
159
+
Added createInternalLayer to Phaser.Tilemap which creates a new internal layer for each non-zero member of the base Tilemap's tilesets list when createLayer is called. (The zero tileset is drawn by the layer created by createLayer).
160
+
161
+
The Tile objects have incorrect data... in the "create from objects" example the "tiles2" tiles which are 70x70 pixels have a width/height of 32x32 (the same as the base tiles from the "ground_1x1" set). I'll take a look at that in a minute after I get this to draw something (the tile used is in the top-left of the image so it should draw even through the sizes are wrong).
162
+
163
+
The image texture appears to also be incorrect in Tile objects that use different tilesets. This might explain why we get garbage drawn to screen, however looking at the phaser.io example I'm seeing the correct tiles being drawn. Need to check all my new code to find how it has got the wrong values.
164
+
165
+
Bug found in TilemapLayerGL where it sets the PIXI baseTexture. I'm seeing the top-left corner of the 70x70 tiles.
166
+
167
+
Added a tileset parameter to the map's layer data objects when creating an 'internal' layer.
168
+
Made TilemapLayerGL grab the tile dimensions from the new tileset parameter instead of relying on the map containing only one size.
169
+
170
+
First working demo with multiple webgl layers each batching tiles from separate tilesets which were all attached to one map layer in the Tiled program.
171
+
Tiles are still turning off too soon at the map edges (exactly like the Canvas version) but that should be fixable with this 'internal layer' approach.
Copy file name to clipboardExpand all lines: src/tilemap/TilemapParser.js
+3-18Lines changed: 3 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -38,13 +38,12 @@ Phaser.TilemapParser = {
38
38
* @param {Phaser.Tilemap} [tileMap=null] - The Phaser.Tilemap this data is created for (used for createLayer to add new layers when mixed tilesets are used).
0 commit comments