Jump to content

Tiles without collision.


Mono2692
 Share

Recommended Posts

Hi, I'm working with Tiled and was able to create a Tile map using a Tile set made from just one image, just for test purposes. I'm following this tutorial https://github.com/mikewesthad/phaser-3-tilemap-blog-posts/tree/master/posts/post-4 but I'm unable to activate and debug the collision for each one of the tiles. I'm using Matter.js physics and also I turned on the debug mode so I can see the collision box for each tile. Any help would be appreciated. Im attaching screen shots of Tiled and the results in the browser, also here is the code. Sorry I don't know how to paste the code with indentation.

import 'phaser';
 
var config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 630,
height: 710,
physics: {
default: 'matter',
matter: {
debug: true
}
},
scene: {
preload: preload,
create: create,
update: update,
}
};
 
function preload ()
{
this.load.image('logo', 'assets/logo.png');
this.load.image('block', 'assets/main_block_1_1.png')
this.load.image('backG', 'assets/main_back_1.png')
this.load.tilemapTiledJSON('map', 'assets/tower_tilemap.json');
}
 
function create ()
{
var map = this.add.tilemap('map');
var tileset = map.addTilesetImage('block_tileset', 'block');
var blocklayer = map.createDynamicLayer('Blocks', tileset, 0, 0);
blocklayer.setCollisionByProperty({ collides: true });
this.matter.world.convertTilemapLayer(blocklayer);
this.matter.world.createDebugGraphic();

Tiled_TileMap.png

Tiled_TileSet.png

Web.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...