Jump to content

collide with a different layer Enemy


lenlac
 Share

Recommended Posts

Hello I have the following Code

        map = this.add.tilemap('world1');                map.addTilesetImage('maze', 'tiles');                layer = map.createLayer('layer1');        layer2 = map.createLayer('layer2');        layer2.enableBody = true;                map.setCollisionBetween(6, 9);        map.setCollisionBetween(11, 14);        map.setCollisionBetween(16, 19);        map.setCollision(3);        map.setCollision(19, true, layer2);                //layer.debug = true;        //layer2.debug = true;        this.physics.arcade.enable(layer2, Phaser.Physics.ARCADE, true);        layer.resizeWorld();        layer2.resizeWorld();

That is in the create function and in the update function

        this.physics.arcade.collide(this.evilcoin, layer);        this.physics.arcade.collide(this.evilcoin, layer2);

The Evil coins collide with layer 1 just fine, but they do not collide with the layer2 at all. I want to basicly create some save havens for my character inside the map.

 

any advice would be great. The layer is drawn correct btw and the block is number 19.

Link to comment
Share on other sites

        map = this.add.tilemap('world1');                map.addTilesetImage('maze', 'tiles');                layer = map.createLayer('layer1');        safezone = map.createLayer('layer2');                        map.setCollisionBetween(6, 9, true, layer);        map.setCollisionBetween(11, 14, true, layer);        map.setCollisionBetween(16, 19, true, layer);        map.setCollision(3, true, layer);        map.setCollision(10, true, safezone);                //layer.debug = true;        safezone.debug = true;        //this.physics.arcade.enable(layer2, Phaser.Physics.ARCADE, true);                layer.resizeWorld();        safezone.resizeWorld();

well i was more specific in my layers and that fixed the issue,

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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