Jingles Posted January 6, 2015 Share Posted January 6, 2015 Hi guys, I'm currently trying to utilize Tiled to add a background image and platforms to a 2D sword-fighting game we're working on. I have created the level and am trying to follow the instructions from the Phaser example noted here (http://examples.phaser.io/_site/view_full.html?d=loader&f=load+tilemap+json.js&t=load%20tilemap%20json) and am running into an error where our game craps out when I try changing from a normal background png image to the tiledmap I've created. Here's my snippet of code from our level.js page: Level.prototype = { preload: function() { //this.engine.load.image('background', 'assets/Journey_Canyon_Solitary_Lookout.png'); this.engine.load.image('tiles', 'assets/sandTileset.png'); this.engine.load.tilemap('myMap', 'assets/Background.json', null, Phaser.Tilemap.TILED_JSON); }, create: function() { // background = this.engine.add.sprite(0, 0, 'background'); map = this.engine.add.tilemap('myMap'); map.addTilesetImage('RealTiles', 'tiles'); layer = map.createLayer('RealTiles'); layer.resizeWorld(); }, update: function() { }} It appears to be an issue with the asynchronous nature of JS as the error I run into has to do with the player class we have trying to update prior to level being created. I have tried to hack around this by creating a variable for levelDone and setting this to true at the end of level creation but it still has some beef with something in the Phaser.min.js file. Sorry in advance, I know this isn't the most succinctly described problem but if anyone has any idea why the simple tiled map I have created isn't loading correctly or in time and how to fix it.... I could really use some help! Thanks,Newb Link to comment Share on other sites More sharing options...
Jingles Posted January 6, 2015 Author Share Posted January 6, 2015 HELP Link to comment Share on other sites More sharing options...
shmikucis Posted January 6, 2015 Share Posted January 6, 2015 I can't help in this case directly, but maybe it is worth trying MightyEditor which is based on Phaser and alternative for tiled? Here is simple example with tiles http://mightyfingers.com/tutorials/display/tilemap/ And here is more complex dungeon mini-game with changing maps http://mightyfingers.com/tutorials/games/dungeon-explorer/ Link to comment Share on other sites More sharing options...
Recommended Posts