Having issues with the map not loading in. Can’t see anything in the code that’s stopping it from doing so but haven’t worked with the maps before. The code from the scene is below and console.log(this.ground) is console logging fine and zero errors in the console. Help really appreciated, you’ll probably see I’m very early learning stage from the code
class Level1 extends Phaser.Scene {
constructor() {
super({key: "Level1" });
}
preload () {
this.load.aseprite('alco', '../assets/animations/StrongAlc.png', '../assets/animations/StrongAlc.json');
this.load.aseprite('chef', '../assets/animations/alcochef.png', '../assets/animations/alcochef.json');
this.load.image('base_tiles', '../assets//maps/level1.png');
this.load.tilemapTiledJSON('tilemap', '../assets/maps/level1.json');
}
create () {
const map = this.make.tilemap({ key: 'tilemap' })
const tileset = map.addTilesetImage('tileset2', 'base_tiles')
this.ground = map.createLayer('groundlayer', tileset, 0, 0)
this.width = 800;
this.height = 640;
let playerPoints = 0;
this.keyF = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.F);
this.keyW = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.W);
this.keyD = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D);
this.keyA = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.A);
this.anims.createFromAseprite('chef', [ 'idleburp', 'standingattack', 'jump', 'run' ]);
this.anims.createFromAseprite('alco');
this.alco = this.physics.add.sprite(this.width/2, (this.height /2) -50, 'alco');
this.chef = this.physics.add.sprite(this.width/50, this.height/2.5, 'chef');
this.chef.body.setCollideWorldBounds(true)
this.physics.add.collider(this.chef, this.ground)
this.chef.sideFacing = 'right'
this.chef.moving = false;
function colliderAlco(sprite) {
playerPoints ++
console.log(playerPoints)
// destroySprite(sprite)
}
this.physics.add.collider(this.chef, this.alco, colliderAlco(this.alco))
this.alco.play({key: 'rotatinglabel', repeat: -1})
// var frameNames = this.textures.get('chef').getFrameNames();
this.chef.play({key: 'idleburp', repeat: -1, ignoreIfPlaying: false})
}
update() {
if(this.keyF.isDown) {
this.chef.play({key: 'standingattack', repeat: 0, ignoreIfPlaying: false})
this.chef.moving = true
}
if(this.keyD.isDown) {
this.chef.play({key: 'run', repeat: -1, ignoreIfPlaying: false})
this.chef.moving = true
this.chef.body.setVelocityX(100);
this.chef.flipX = false
if(this.chef.facing === 'left') {
return this.chef.facing === 'right'
}
}
if(this.keyW.isDown) {
this.chef.play({key: 'jump', repeat: 0, ignoreIfPlaying: false})
this.chef.moving = true
}
if(this.keyA.isDown) {
this.chef.play({key: 'jump', repeat: 0, ignoreIfPlaying: false})
this.chef.moving = true
this.chef.body.setVelocityX(-100);
this.chef.flipX = true
if(this.chef.facing === 'right') {
return this.chef.facing === 'left'
}
}
}
}
function destroySprite(sprite) {
sprite.destroy();
}
export default Level1;