Jump to content

Jump through a tile from underneath


clguy
 Share

Recommended Posts

Hi!

I’m new to Phaser 3 and I’m testing a lot of things to create a little platformer, right now I’m using Tiled, and I already did tiles that collide with the player, but I don’t know how to avoid colliding with the bottom part of these tiles. So I’m asking for help.

 

Thanks.

Link to comment
Share on other sites

Hey, if you use arcade physics, you can do this:
 

const map = this.make.tilemap({ key: key, tileWidth: 12, tileHeight: 12}); 
// init the tilemap, setup the right tile sizes
const levelTiles = map.createDynamicLayer(2, tileset, 0, 0); //setting up a new tilemap layer
//I think note doesn't matter if it's static ot dynamic for your purpose

levelTiles.layer.data.forEach((row) => { // here we are iterating through each tile.
			row.forEach((Tile) => {
				switch(Tile.index) { // the index, you can see in tiled: it's the ID+1
					case 31: Tile.visible = false; break;
					case 485: // <- this tile only colides top
						Tile.collideDown = false;
						Tile.collideLeft = false;
						Tile.collideRight = false;
						break;
					case 545: // <- this tile only colides top
						Tile.collideDown = false;
						Tile.collideLeft = false;
						Tile.collideRight = false;
						break;
					default: break;
				}
			})
		});

Hope that this will helps :)
If you got any questions, don't hesitate to ask.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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