Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading tilemap with preloaded json object not working #9

Open
matthias-herbst opened this issue Jan 26, 2018 · 1 comment
Open

Loading tilemap with preloaded json object not working #9

matthias-herbst opened this issue Jan 26, 2018 · 1 comment

Comments

@matthias-herbst
Copy link

Passing a preloaded json object to the game.load.tilemap()-function breaks map.

URL parameter is required.
Phaser tilemap accepts json object instead of a url.

Is there any workaround?

@matthias-herbst
Copy link
Author

Found a solution on my own.
I think this would be a great addition to your plugin.

Extend functionality of the Loader.tilemap function (L. 526ff:)

Phaser.Loader.prototype.tilemap = function (t, e, i, a) {
      r.call(this, t, e, i, a);
      // if url == null && json data passed to load tilemap function
      if(e == null && i != null) {
        var cacheKey = n(t);
        this.game.cache.addJSON(cacheKey, null, this.game.cache.getTilemapData(t).data);
      }
      else { this.json(n(t), e); }
 };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant