zerius Posted June 18, 2016 Share Posted June 18, 2016 Hi everyone, I am a new developer trying out phaser for a final project for my course and I am trying to create a scrolling platformer. I am having some trouble loading in the tiled map however, really looking for any insight or a possible common bug. I have followed the guide at http://phaser.io/examples/v2/loader/load-tilemap-json but to no avail... Below is my code so far: ------------------------------------------------------------------------------main.js------------------------------------------------------------------------------ var gameState = {preload: preload, create: create, update: update, render: render}; var game = new Phaser.Game(770, 630, Phaser.AUTO, 'gameDiv', gameState); var socket; var localPlayer; var health = 5; var remotePlayers = {}; var REMOTE_PLAYERS = {}; var specialC; var remoteBullets = {}; var bulletTime = 0; var bullets; var bullet; var bulletHitPlayer = false; var afterHitSpeed = 0.5; var map var blockedlayer function preload() { game.load.tilemap('level1', 'assets/tilemaps/map10.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('gameTiles', 'assets/images/orig_tiles_spritesheet2.png'); } function create() { console.log("got onto create") game.stage.backgroundColor = '#107878'; map = game.add.tilemap('level1'); map.addTilesetImage('orig_tiles_spritesheet', 'gameTiles'); blockedlayer = map.createLayer('blockedLayer'); blockedlayer.resizeWorld(); } function update(){ } function render(){ } ------------------------------------------------------------------------------JSON file------------------------------------------------------------------------------ { "height":22, "layers":[ { "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 101, 133, 133, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 133, 133, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 133, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 141, 133, 0, 0, 0, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 13, 0, 0, 0, 13, 13, 13, 0, 0, 0, 0, 13, 13, 13, 13, 0, 0, 0, 141, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 0, 0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0, 0, 0, 0, 133, 133, 133, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 133, 133, 133, 0, 0, 0, 0, 0, 0, 87, 0, 0, 0, 85, 0, 0, 0, 0, 2, 141, 0, 0, 0, 0, 0, 0, 0, 0, 133, 133, 0, 0, 0, 133, 133, 133, 133, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 133, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 133, 0, 0, 0, 133, 0, 133, 0, 0, 0, 87, 0, 0, 29, 0, 0, 0, 0, 0, 141, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 133, 133, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 133, 133, 133, 133, 133, 133, 0, 0, 0, 0, 0, 133, 133, 0, 0, 0, 87, 0, 0, 17, 0, 0, 126, 113, 113, 153, 0, 0, 0, 0, 133, 133, 133, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 133, 133, 133, 133, 133, 133, 133, 133, 0, 0, 0, 0, 0, 133, 133, 133, 0, 0, 0, 0, 0, 133, 133, 133, 133, 133, 133, 0, 0, 0, 0, 133, 133, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 87, 87, 87, 0, 29, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 133, 133, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 133, 133, 133, 133, 0, 0, 133, 0, 0, 0, 133, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 87, 87, 87, 29, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 133, 133, 133, 133, 133, 0, 133, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 0, 0, 133, 133, 133, 133, 133, 133, 0, 133, 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, 0, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 116, 104, 104, 104, 104, 104, 104, 104, 116, 104, 104, 104, 104, 104, 104, 104, 104, 116, 104, 104, 104, 104, 104, 104, 104, 104, 116, 104, 104, 104, 104, 104, 104, 104, 104, 116, 104, 104, 104, 104, 104, 104, 104, 104, 116, 104, 104, 104, 104, 104, 104, 104, 104, 116, 104, 104, 104, 104, 104, 104, 104, 116, 104, 104, 104, 104, 104, 133, 104, 104, 116, 104, 104, 104, 104, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 133, 133, 153, 153, 153, 153, 153, 153, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133], "height":22, "name":"blockedLayer", "opacity":1, "type":"tilelayer", "visible":true, "width":110, "x":0, "y":0 }], "nextobjectid":1, "orientation":"orthogonal", "renderorder":"right-down", "tileheight":70, "tilesets":[ { "columns":12, "firstgid":1, "image":"test_scroller\/assets\/images\/orig_tiles_spritesheet.png", "imageheight":936, "imagewidth":914, "margin":0, "name":"orig_tiles_spritesheet", "spacing":2, "tilecount":156, "tileheight":70, "tilewidth":70, "transparentcolor":"#00eeff" }, { "columns":11, "firstgid":157, "image":"test_scroller\/assets\/images\/tiles_spritesheet.png", "imageheight":934, "imagewidth":790, "margin":0, "name":"tiles_spritesheet", "spacing":2, "tilecount":143, "tileheight":70, "tilewidth":70 }], "tilewidth":70, "version":1, "width":110 } I do get this warning on my console log "Phaser.Tileset - orig_tiles_spritesheet image tile area is not an even multiple of tile size" but I don't think it is causing the issue... Any insight at all would be greatly appreciated!!! Thank you! Link to comment Share on other sites More sharing options...
DecodersLord Posted June 13, 2017 Share Posted June 13, 2017 Hey I know I am late but I am also brand new to phaser and suffering from the same issue for past 4 days.I wonder if you have found the answer and would like to help me on it please?? Link to comment Share on other sites More sharing options...
gimpycoder Posted June 14, 2017 Share Posted June 14, 2017 DecodersLord, this post is really old, so I think that you should create a new thread with your problem, and provide the code in question. I was looking at this before realizing the date posted (I'm new to this place too), and I think that the offending line is: map.addTilesetImage('orig_tiles_spritesheet', 'gameTiles'); We note that in documentation: https://phaser.io/docs/2.6.2/Phaser.Tilemap.html#addTilesetImage The tileset 'orig_tiles_spritesheet' is never actually loaded as image in preload, so it would suggest that this resource was simply not available for use. The better way to load this image would have been: map.addTilesetImage('gameTiles'); Except, it's hard to say anything about anything at this point. 1) not very experienced, 2) old -- could be old versions and such. But if that's your problem too, cool. However, if not, you should create a new thread. Link to comment Share on other sites More sharing options...
Recommended Posts