Harrisyu Posted February 27, 2017 Share Posted February 27, 2017 When I start using melonsJS, I find out that integrate with Tiled make melonJS almost an editor base engine. So I want to visually place player and enemy using there tile image as entity defind. Problem is melonJS will load everything you defind, including these helper tileset. And I post my question here:http://www.html5gamedevs.com/topic/28667-feature-request-or-how-to-load-level-without-loading-all-tileset/ Now I now how to replace these helper object in Tiled's json data , before building the map. Here is the code in coffee: convertHelperTileset = (mapJson, tilesetName)-> tempArray =  for tileset in mapJson.tilesets if tileset.name isnt tilesetName tempArray.push tileset else #now covert all objects using this tileset for layer in mapJson.layers if layer.type is "objectgroup" for obj in layer.objects if obj.gid? #object that has gid is a tile object if obj.gid>=tileset.firstgid and obj.gid<=tileset.firstgid+tileset.tilecount delete obj.gid #will recognize as a rectangle object obj.y -= obj.height #this is the pivot point diffrent between tile and rectangle mapJson.tilesets = tempArray return After map are loaded,using me.loader.getJSON(mapName) to get the map json object, and then use this function to convert all the helper tileset. That is it. Quote Link to comment Share on other sites More sharing options...
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.