Currently, I am working on developing a game using the Phaser engine and utilizing the 'Tiled' application to create my own tilemap.
One of the challenges I am facing is managing multiple layers within this tilemap. Specifically, I have 6 different layers:
- "Background"
- "WallBlocks"
- "Grass"
- "SpikeAnimation"
- "DiamondAnimation"
- "SlimeAnimation"
Below is an excerpt from my Game.js file:
SleepSim.Game = function (game) {
this.map;
this.Background;
this.WallBlocks;
this.Grass;
this.SpikeAnimation;
this.DiamondAnimation;
this.SlimeAnimation;
}
SleepSim.Game.prototype = {
create: function () {
this.world.setBounds(0,0,5000,1000);
this.map = this.add.tilemap('gameWorld');
this.map.addTilesetImage('gameworld', 'tiles');
this.Background = this.map.createLayer('Background');
this.Background.resizeWorld();
this.WallBlocks = this.map.createLayer('WallBlocks');
this.Grass = this.map.createLayer('Grass');
this.SpikeAnimation = this.map.createLayer('SpikeAnimation');
this.DiamondAnimation = this.map.createLayer('DiamondAnimation');
this.SlimeAnimation = this.map.createLayer('SlimeAnimation');
},
update: function() {
if(this.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
this.camera.y += 10;
}
else if (this.input.keyboard.isDown(Phaser.Keyboard.UP)){
this.camera.y -= 10;
}
if (this.input.keyboard.isDown(Phaser.Keyboard.LEFT)){
this.camera.x -= 10;
}
else if (this.input.keyboard.isDown(Phaser.Keyboard.RIGHT)){
this.camera.x += 10;
}
}
}
For testing purposes, I currently have the camera set up in a way that allows it to move freely through the map to check loading functionality.
If there are any issues with the formatting of this question, please excuse me as this is my first time posting! Any assistance or guidance would be greatly appreciated.