3
\$\begingroup\$

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?

Below is the critical part of the collision code.(And Also I have all my codes packed and you can download with below hyperlink.)

//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
this.physics.startSystem(Phaser.Physics.ARCADE);


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

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



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

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

https://db.tt/AAdpu3zd

\$\endgroup\$
0
\$\begingroup\$

There is an isometric plugin for phaser with physics capabilities that can help you with collisions.

Here's the link:

http://rotates.org/phaser/iso/

Check out their physics sample.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.