Jump to content

I don't want overlapping sprite when they collide with a tilemap


gferrari
 Share

Recommended Posts

Hi everybody, 
I have two sprites, with physic enabled and I set the x velocity both, and they collide with the limite of game world  without problem and without overlapping if they are in the same x line. 
But If they collide with a tilemap, the first sprite is ok, but the next when arrive with the first sprite... it's overlapping with the first.
 
I'm using ARCADE physic and Phaser, the last version, v2.0.5 
 
I don't have the code right now but I remember that:
 
 
//In create
game.physics.startSystem(Phaser.Physics.ARCADE);
 
map = game.add.tilemap('level1');
map.addTilesetImage('mindout-level1', 'tiles');
map.setCollision(1);
layer = map.createLayer('level1');
layer.resizeWorld();
 
box1 = game.add.sprite(100, 500, 'box1');
game.physics.enable(box1);
player.body.collideWorldBounds = true;
 
box2 = game.add.sprite(100, 500, 'box2');
game.physics.enable(box2);
box2.body.collideWorldBounds = true;
 
 
//In the updaet code
game.physics.arcade.collide(box1, layer);
game.physics.arcade.collide(box2, layer);    
game.physics.arcade.collide(box1, box2);
 
What I miss with the layer? 
 
Thanks!

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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