Jump to content

Add Collision for diffrent tile map layers


gwartney
 Share

Recommended Posts

So I have not quite figured this out. But I am trying to set two diffrent collisions for two seprate tile map layers. For instance I have a ground layer that the player can run on and a obstacle such as spikes that a player will be able to run into. But I dont want it to overlap. So I have attempted something like this in the create function. 

map = game.add.tilemap('GroundTilePrototype');
		// Add the tileset to the map
		map.addTilesetImage('GroundTileSet');
		// Create the layer by specifying the name of the Tiled layer
		layer = map.createLayer('Tile Layer 1');
		// Set the world size to match the size of the layer
		layer.resizeWorld();
		// Enable collisions for the first tilset element
		map.setCollision(2);

		layer2 = map.createLayer('Tile Layer 2');
		//set spike colosion
		map.setCollision(1);

 And I thought I could do something like this in the update function. But It will only work for the first layer. Could any one point me toward the right direction?

game.physics.arcade.collide(player,layer);
game.physics.arcade.collide(player,layer2);

Thanks for the help.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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