Skip to content

Commit 7410814

Browse files
committed
CSV Tilemap tiles would incorrectly set the Tile layer reference, causing collision to fail (thanks @Chapelin, fix phaserjs#692)
1 parent 57775e9 commit 7410814

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ Version 2.0.4 - "Mos Shirare" - in development
154154
* P2.Body.loadPolygon has been updated to correct center of mass issues (thanks @georgiee, fix #749)
155155
* Game checks if window.console exists before using it (should fix IE9 issues when dev tools are closed), however it is still used deeper in Pixi.
156156
* Masks now work when used in RenderTextures / CacheAsBitmap and Filters (pixi.js update)
157-
* Fixed bug where stroked text sometimes got clipped (pixi.js update)
158-
* Fixed Polygon.contains for coordinates to the left of the polygon (thanks @vilcans, fix #766)
159-
* Fixed issue where game pause/resume could incorrectly increment paused Timers (thanks @georgiee, fix #759)
160-
* Fixed issue where Animations resuming from a pause would skip frames (thanks @merixstudio, fix #730)
157+
* Stroked text sometimes got clipped (pixi.js update)
158+
* Polygon.contains now works for coordinates to the left of the polygon (thanks @vilcans, fix #766)
159+
* Game pause/resume could incorrectly increment paused Timers (thanks @georgiee, fix #759)
160+
* Animations resuming from a pause no longer skip frames (thanks @merixstudio, fix #730)
161161
* Tilemap.fill would throw an error if called on a blank tilemap full of null values (thanks @DrHackenstein, fix #761)
162162
* LoaderParser.bitmapFont updated so xml parsing works properly on IE9 (thanks @georgiee)
163-
* Fixed an issue where Sounds that had been paused via game code would un-mute if the game paused and resumed.
164-
* Fixed Timer issue where pausing then restarting could add to the duration of running manual timers (fix #759)
163+
* Sounds that had been paused via game code would un-mute if the game paused and resumed.
164+
* CSV Tilemap tiles would incorrectly set the Tile layer reference, causing collision to fail (thanks @Chapelin, fix #692)
165165

166166

167167
### ToDo

src/tilemap/Tilemap.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ Phaser.Tilemap = function (game, key, tileWidth, tileHeight, width, height) {
6666
*/
6767
this.orientation = data.orientation;
6868

69+
/**
70+
* @property {number} format - The format of the map data, either Phaser.Tilemap.CSV or Phaser.Tilemap.TILED_JSON.
71+
*/
72+
this.format = data.format;
73+
6974
/**
7075
* @property {number} version - The version of the map data (as specified in Tiled, usually 1).
7176
*/
@@ -263,7 +268,7 @@ Phaser.Tilemap.prototype = {
263268
{
264269
tileset = this.getTilesetIndex(tileset);
265270

266-
if (tileset === null)
271+
if (tileset === null && this.format === Phaser.Tilemap.TILED_JSON)
267272
{
268273
console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "' + key + '"');
269274
return null;

src/tilemap/TilemapParser.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Phaser.TilemapParser = {
8989

9090
for (var x = 0; x < column.length; x++)
9191
{
92-
output[y][x] = new Phaser.Tile(0, parseInt(column[x], 10), x, y, tileWidth, tileHeight);
92+
output[y][x] = new Phaser.Tile(map.layers[0], parseInt(column[x], 10), x, y, tileWidth, tileHeight);
9393
}
9494

9595
if (width === 0)
@@ -98,6 +98,7 @@ Phaser.TilemapParser = {
9898
}
9999
}
100100

101+
map.format = Phaser.Tilemap.CSV;
101102
map.name = key;
102103
map.width = width;
103104
map.height = height;
@@ -118,6 +119,7 @@ Phaser.TilemapParser = {
118119

119120
/**
120121
* Returns an empty map data object.
122+
*
121123
* @method Phaser.TilemapParser.getEmptyData
122124
* @return {object} Generated map data.
123125
*/
@@ -198,6 +200,7 @@ Phaser.TilemapParser = {
198200
map.tileWidth = json.tilewidth;
199201
map.tileHeight = json.tileheight;
200202
map.orientation = json.orientation;
203+
map.format = Phaser.Tilemap.TILED_JSON;
201204
map.version = json.version;
202205
map.properties = json.properties;
203206
map.widthInPixels = map.width * map.tileWidth;
@@ -242,7 +245,7 @@ Phaser.TilemapParser = {
242245

243246
// Loop through the data field in the JSON.
244247

245-
// This is an array containing the tile indexes, one after the other. null = no tile, everything else = the tile index (starting at 1 for Tiled, 0 for CSV)
248+
// This is an array containing the tile indexes, one after the other. -1 = no tile, everything else = the tile index (starting at 1 for Tiled, 0 for CSV)
246249
// If the map contains multiple tilesets then the indexes are relative to that which the set starts from.
247250
// Need to set which tileset in the cache = which tileset in the JSON, if you do this manually it means you can use the same map data but a new tileset.
248251

@@ -255,7 +258,7 @@ Phaser.TilemapParser = {
255258
}
256259
else
257260
{
258-
row.push(null);
261+
row.push(new Phaser.Tile(layer, -1, x, output.length, json.tilewidth, json.tileheight));
259262
}
260263

261264
x++;

0 commit comments

Comments
 (0)