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
Notes about failed attempt to hack in the new layers approach quickly (proof of concept). The class relationship is more complex than it first appears and there are some odd connections and label namings which make it hard to manipulate quickly.
layer = map.createLayer(0, undefined, undefined, undefined, true); <-- true specifies to use the new PIXI tilemap system
116
116
117
-
TODO: bug - in the sci-fly demo there is a new problem with collisions when the map has scrolled, I'm guessing this is some sort of scroll offset conflict between the display and the collision system.
117
+
bug - in the sci-fly demo there is a new problem with collisions when the map has scrolled, I'm guessing this is some sort of scroll offset conflict between the display and the collision system.
118
118
119
119
Testing the system on tilemaps with borders and tiles with margins ("fill-tiles" example)... it works! This vindicates the change of approach because that was going to be a real pain to support if I had to recreate all the stuff that Phaser already handles out of the box!
120
120
121
121
Removed requirement for pixiTest parameter in createLayer by using renderType instead. I don't need to use WEBGL because it's currently hard-wired in Phaser.Game constructor code (which I had forgotten about) so all examples running locally will be using the new renderer.
122
122
123
-
TODO: another bug - when scrolling not only are the collisions off, the redrawing tile area gets smaller as we move away from the map origin. This could be linked to the collisions via the scroll offsets being wrong, however the area of map which is drawn appears to be in the correct place... are there two separate scroll offsets in this system? There are some calculations for start/end of drawing region, might be a good place to start looking.
123
+
another bug - when scrolling not only are the collisions off, the redrawing tile area gets smaller as we move away from the map origin. This could be linked to the collisions via the scroll offsets being wrong, however the area of map which is drawn appears to be in the correct place... are there two separate scroll offsets in this system? There are some calculations for start/end of drawing region, might be a good place to start looking.
124
124
125
-
TODO: need to make the PIXI.Tilemap access multiple source textures and use tile width and height from the batch buffer data in order to reinstate the Phaser multiple tilesets per map capabilities.
125
+
I need to make the PIXI.Tilemap access multiple source textures and use tile width and height from the batch buffer data in order to reinstate the Phaser multiple tilesets per map capabilities. NOTE: decided this is a stupid approach, see task list below for better idea.
126
126
127
127
After testing, *all* examples seem to work (with these three restrictions)
128
128
129
129
Found both bugs, I was effectively applying the scroll twice because the new batch list calculates the offsets internally and I was still applying it as a uniform to the webgl shader.
130
130
131
131
Remaining Task Summary:
132
132
133
-
- Change the map parser, so that when additional tilesets are encountered, it creates a new Tilemap Layer for each and keeps data for only one tileset per layer.
133
+
- Change the map parser, so that when additional tilesets are encountered, it creates a new Tilemap Layer for each and keeps data for only one tileset per layer. (added TODO: comments into TilemapParser.js for one possible approach to this).
134
134
- Store the tileset index or reference in the Tile structure, deprecate resolveTileset and any other related code
135
135
- Add alpha blending to the shader, calculate the 'final' alpha by multiplying the layer's worldAlpha with the tile.alpha
136
-
- Add scaling to the shader, use the layer's worldScale
136
+
- Add scaling to the shader, use the layer's worldScale. (See if rotation can be easily supported too, while doing this)
137
137
- Optimise the drawing to avoid degenerate triangles where possible, e.g. each row should be a single tri-strip without degenerates in it for faster drawing
138
138
139
+
Known bugs:
140
+
- Blank Tilemap example isn't drawing, may not handle multiple layers correctly.
139
141
142
+
Attempted a quick hack to test the new layers approach but got bogged down in the messy class relationship here.
140
143
144
+
Some notes for later:
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
+
- 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.
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
+
- Tilemap.createLayer is called by Examples after the Tilemap has been created and parsed.
141
150
142
-
143
-
151
+
So, I can't create new TilemapLayer objects in TilemapParser because it will preempt Tilemap.createLayer. Or maybe I can, these TilemapLayer objects will be internal (hidden)...? There aren't any later calls in the Examples which I can extend or adapt, so that might have to be the solution.
0 commit comments