LoginSignup
0
0

More than 5 years have passed since last update.

RPG風マップを実現する Egret公式推奨の方法 (失敗編2) GZIP/ZLIB 圧縮された TMX はサポートされていない

Posted at
assetsmanager.js:1177 Uncaught TypeError: Cannot read property 'getResByUrl' of undefined
    at Object.getResByUrl (assetsmanager.js:1177)
    at TMXImage.loadImage (tiled.js:1253)
    at new TMXImage (tiled.js:1187)
    at new TMXTileset (tiled.js:2568)
    at TMXTilemap.readMapObjects (tiled.js:1041)
    at TMXTilemap.getLayers (tiled.js:957)
    at TMXTilemap.render (tiled.js:946)
    at Main.onMapComplete (Main.ts:54)
    at WebHttpRequest.EventDispatcher.$notifyListener (egret.js:349)
    at WebHttpRequest.EventDispatcher.dispatchEvent (egret.js:328)

下記の「instance.getResByUrl」のinstanceが undefinedになっているかと思われます

assetmanager.js
    function getResByUrl(url, compFunc, thisObject, type) {
        if (type === void 0) { type = ""; }
        return compatiblePromise(instance.getResByUrl(url, compFunc, thisObject, type));
    }
    RES.getResByUrl = getResByUrl;

本来であればloadConfigの中でinstanceが初期化されるようです

assetmanager.js
    function loadConfig(url, resourceRoot) {
:
        if (!instance)
            instance = new Resource();
:
    }

ということで Main.tsで通常の RES.loadConfigを呼んであげます

Main.ts
-    private onAddToStage () {
+    private async onAddToStage () {
+        await this.loadResource()
:
    }
:
+    private async loadResource() {
+ :
+            await RES.loadConfig("resource/default.res.json", "resource/");
+            await RES.loadGroup("preload", 0, loadingView);
+ :
+    }

今度は Uncaught Error: GZIP/ZLIB compressed TMX Tile Map not supported!という
TMXファイルの形式がサポートされていない形式だと怒られました

tiled.js:3096 Uncaught Error: GZIP/ZLIB compressed TMX Tile Map not supported!
    at Function.Base64.decompress (tiled.js:3096)
    at Function.TMXUtils.decode (tiled.js:3166)
    at new TMXLayer (tiled.js:539)
    at TMXTilemap.parseLayer (tiled.js:1114)
    at TMXTilemap.readMapObjects (tiled.js:1044)
    at TMXTilemap.getLayers (tiled.js:957)
    at TMXTilemap.render (tiled.js:946)
    at Main.onMapComplete (Main.ts:56)
    at WebHttpRequest.EventDispatcher.$notifyListener (egret.js:349)
    at WebHttpRequest.EventDispatcher.dispatchEvent (egret.js:328)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0