Having A Problem Loading A Tilemap Into Phaser 3
I've been having a problem loading a tilemap that I created with 'tiled', I looked up the phaser 3 examples, I even copied pasted their file and png tile image into my project fold
Solution 1:
var config = {
type: Phaser.WEBGL,
width: 400,
height: 288,
parent: 'phaser-example',
loader: {
baseURL: 'https://raw.githubusercontent.com/nazimboudeffa/assets/master/maps/',
crossOrigin: 'anonymous'
},
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
var map;
var cursors;
var player;
var groundLayer;
function preload ()
{
this.load.image('tileset', 'sunny-land/tileset.png');
this.load.tilemapTiledJSON('map', 'sunny-land/level0.json');
}
function create ()
{
map = this.make.tilemap({ key: 'map' });
var groundTiles = map.addTilesetImage('tileset');
map.createStaticLayer('ground', groundTiles, 0, 0);
//map.createStaticLayer('jumpThrough', groundTiles, 0, 0);
}
<script src="//cdn.jsdelivr.net/npm/phaser@3.17.0/dist/phaser.min.js"></script>
Post a Comment for "Having A Problem Loading A Tilemap Into Phaser 3"