// Import map from Tiled
this.map = this.make.tilemap({ key: 'myBeautifulMap' });
this.platform = this.map.createLayer('platform', this.tileset);
// Apply collision to ALL tiles from this Layer
this.platform.setCollisionByExclusion(-1, true);
// disable one side collision so character can jump up trough it
this.platform.forEachTile(tile => {
if (tile.index > 0){
tile.setCollision(false, false, true, false);
}
});
// Allow jump down
// This part shoudl check if the tiles the character is standing on are part of the 'platform' Layer
if (this.keyboard.S.isDown) {
this.body.checkCollision.down = false;
this.scene.time.addEvent({
delay: 400,
callback: () => {
this.body.checkCollision.down = true;
},
callbackScope: this
});
}