Jump to content

problem with Phaser collissions after tilemap scaling


lego_brick
 Share

Recommended Posts

Hi, 

I have tilest 16x16. It is exported to json format. I used Tiled app.

It works fine until using scaling function.  After that colission is not working.
 

Here's my code:

create: function() {

this.map = this.game.add.tilemap('tiled');

this.map.addTilesetImage('tiled', 'tiles');

this.layer = this.map.createLayer('background');

this.layer.scale.setTo(3, 3); //It disables collissions

this.layer.resizeWorld();

this.walls = this.map.createLayer('walls');
this.walls.scale.setTo(3, 3); //It disables collissions

this.layer.resizeWorld();

....

this.map.setCollisionBetween(1, 2000, true, 'walls');

this.sprite = this.game.add.sprite(70, 70, 'soldier');

this.sprite.anchor.setTo(0.5, 0.5);

this.game.physics.enable(this.sprite);

this.sprite.body.setSize(8, 8, 4, 4);

this.sprite.scale.setTo(3, 3);

}

update: function() {

this.game.physics.arcade.collide(this.sprite, this.walls);

...

}

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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