NoxBrutalis Posted July 7, 2018 Share Posted July 7, 2018 Hi, Im new to phaser, and am trying to use a tiled tile map. I tried various ways myself, without any joy, so I decided to copy paste one of the examples from phaser3, - the tilemap example : http://labs.phaser.io/view.html?src=src\game objects\tilemap\static\tiled-json-map.js the example works online, but when i alter it to use my assets, it doesn't draw anything! here's the code I'm using: var config = { type: Phaser.AUTO, width: 800, height: 600, backgroundColor: '#2d2d2d', parent: 'phaser-example', pixelArt: true, scene: { preload: preload, create: create, update: update } }; var game = new Phaser.Game(config); var controls; function preload () { this.load.image('tiles', 'assets/tiles.png'); this.load.tilemapTiledJSON('map', 'assets/tiledMap.json'); } function create () { var map = this.make.tilemap({ key: 'map' }); // The first parameter is the name of the tileset in Tiled and the second parameter is the key // of the tileset image used when loading the file in preload. var tiles = map.addTilesetImage('tileSheet', 'tiles'); // You can load a layer from the map using the layer name from Tiled, or by using the layer // index (0 in this case). var layer1 = map.createStaticLayer('floor', tiles, 0, 0); var layer2 = map.createStaticLayer('walls', tiles, 0, 0); this.cameras.main.setBounds(0, 0, map.widthInPixels, map.heightInPixels); var cursors = this.input.keyboard.createCursorKeys(); var controlConfig = { camera: this.cameras.main, left: cursors.left, right: cursors.right, up: cursors.up, down: cursors.down, speed: 0.5 }; controls = new Phaser.Cameras.Controls.FixedKeyControl(controlConfig); var help = this.add.text(16, 16, 'Arrow keys to scroll', { fontSize: '18px', padding: { x: 10, y: 5 }, backgroundColor: '#000000', fill: '#ffffff' }); help.setScrollFactor(0); } function update (time, delta) { controls.update(delta); } and here's a link to the tilemap and the tilesheet. https://1drv.ms/f/s!An8drR4PnP4m1Q8Y25sa1GX1tVv2 The example game runs without any errors, but doesn't show the image. Thanks a lot for your time. Link to comment Share on other sites More sharing options...
NoxBrutalis Posted July 7, 2018 Author Share Posted July 7, 2018 Update/Answer: Sick of being stuck, I decided to mess around with an image, weighing up the idea of just using a big image instead of a Tmap, as I was experimenting, and using the scrolling screen code in the above copied demo, I found the structure from my map, it simply wasn't on the screen, and because the map was empty except for a building off-centre, it looked empty (no way to even tell that the scene was truly scrolling). So, sorry to anyone who may have looked at this - stupid mistake ? Link to comment Share on other sites More sharing options...
Recommended Posts