Jump to content

Can't make sprite collide with tilemap made with Tiled


Recommended Posts

Hi all, I'm a newbie who just started learning phaser.

I have created a tile map with Tiled.

It is composed of two tiled layer: background & collision.

In collision layer I put some walls.

And in the game code,

I have loaded tilemaps, create them, and they shows perfectly.

Then I set the collision, and sense the collision in update();

I think it should make the sprite collide with wall, but it didn't.. 

I tried adding "collison" properties in Tiled as I found from some tutorials, but it didn't work either..

Can someone help me? 


I have my all code & img & json packed here... Thanks~


//load tilemaps in preload.
this.load.tilemap('zombieset', 'assets/tilemaps.json', null, Phaser.Tilemap.TILED_JSON);
this.load.image('tiles', 'assets/tileset.png');

//start physic systems

//create tiles, and it shows perfectly.
this.map = this.add.tilemap('zombieset');
this.map.addTilesetImage('tileset1', 'tiles');

//set collision.
this.layer = this.map.createLayer('background');
this.layer = this.map.createLayer('collision');

//sensor collison in update()
this.physics.arcade.collide(this.asuna, this.layer);


Link to comment
Share on other sites


  • Recently Browsing   0 members

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