Jump to content

Changing tileset for a tile


Peter79
 Share

Recommended Posts

Hello,

I'm trying to implement terraforming on an isometric tile map and I'm using multiple tilesets (with different offsets) to simulate elevation. Using this code when I click on a tile.

tile.tileset = me.game.world.getChildByName("Terrain")[0].tilesets.tilesets[2];

However, I get "Uncaught TypeError: Cannot read property 'offset' of undefined" on melonjs.js:24629.

It seems to be drawing the tile as the new tileset is being set. Is there a way to pause the drawing of tiles when I change the tileset or is there a better way to change the tileset for a tile?

 

I'm using the MelonJS 5.1.0 with the boilerplate code on the latest version of Chrome for Mac.

 

Many Thanks,

Peter.

Link to comment
Share on other sites

Hi, sorry fo the late feedback (Chinese holiday season in this part of the world) and yes indeed, the solution was to also update the "corresponding" tileId :)

 

I do wonder though if manipulating directly those references/values is a good idea, and if we should not rather have something that better abstract the tile(set) "architecture" (e.g. if you change your tileset in Tiled, your index here above could then be incorrect?)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...