recursor94 Posted March 15, 2014 Share Posted March 15, 2014 After following the first tutorial I've been trying my hand at a simple platformer. I used a very simple png and map editor to create the first level and I looked at a few tutorials online to figure out how to import created levels. I came up with this: preload: function(){ this.game.load.image('sky', 'assets/BackgroundGradient.png'); this.map = this.game.load.tilemap('map', 'assets/level1.json', null, Phaser.Tilemap.TILED_JSON); this.game.load.image('tiles', 'assets/Dirt-Grass-1.png'); //this.game.load.tileset('tiles', 'assets/Dirt-Grass-1.png', 64, 64); Commented out because of error. this.map.addTileSetImage('tiles','tiles'); }but when I try to run it, I come across these errors in firefox and chrome respectively.this.map.addTileSetImage is not a functionUncaught TypeError: Object [object Object] has no method 'addTileSetImage' I run into these errors both when I'm trying to use game.load.tileset and this.map.addTileSetImage. I know that the objects exist because I have no problem calling other methods on them. What am I doing wrong? The only thing I can think of is that I'm not passing the correct paramaters. In which case I'm not sure what I should be passing instead. Link to comment Share on other sites More sharing options...
GNUton Posted March 15, 2014 Share Posted March 15, 2014 Here is the correct way to use the APIs.map must contain the object returned by game.add.tilemap('map'); function preload(){... game.load.tilemap('map', 'assets/tilemaps/map.json', null, Phaser.Tilemap.TILED_JSON); // to load the tileset game.load.image('tiles', 'assets/tilemaps/super_mario.png');...} function create(){ // Adds map to the game map = game.add.tilemap('map'); map.addTilesetImage('SuperMarioBros-World1-1', 'tiles');} Link to comment Share on other sites More sharing options...
Recommended Posts