Skip to content

Commit 1dbfaba

Browse files
committed
Merge pull request phaserjs#2084 from noidexe/patch-2
Add support for TiledJSON with base64 encoding
2 parents 1d05f27 + 8528f0c commit 1dbfaba

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/tilemap/TilemapParser.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,19 @@ Phaser.TilemapParser = {
232232
}
233233

234234
var curl = json.layers[i];
235+
236+
// Base64 decode data if necessary
237+
// NOTE: uncompressed base64 only.
238+
if (!curl.compression && curl.encoding && curl.encoding === "base64") {
239+
var binaryString = window.atob(curl.data);
240+
var len = binaryString.length;
241+
var bytes = new Array( len );
242+
for (var i = 0; i < len; i+=4) {
243+
bytes[i/4] = binaryString.charCodeAt(i);
244+
}
245+
curl.data = bytes;
246+
}
247+
235248

236249
var layer = {
237250

0 commit comments

Comments
 (0)