Jump to content

[Help] Wired problem with tilemap collision


shohan4556
 Share

Recommended Posts

Hi, I have create a simple tilemap using tiled editor the map has just single layer but when I tried to collide my player with tilemap then this wired problem happened.

Sometimes my player collide correctly sometime it overlapping. pic more more details understanding.

here is the minimal code 

for full project https://github.com/shohan4556/Cowboy-Shooter/tree/master/script

MyGame.playState.prototype = {

    create: function () {
        console.log(game.state.getCurrentState());
        this.game.physics.startSystem(Phaser.Physics.ARCADE);
      
        this.map = this.game.add.tilemap('tilemap');
        this.map.addTilesetImage('sheet','tileset'); 
        // create the layer 
        this.layer = this.map.createLayer(0); 
        this.layer.resizeWorld();
        
        this.map.setCollisionBetween(0, 133);

    },

    update: function () {
        this.game.physics.arcade.collide(this.player, this.layer);

    },

the first image is overlapping and the second image is colliding with the tile. it happens randomly when I move my player around.

p1.PNG

p2.PNG

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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