I just can't understand why is my enemy behind the background / tilemap. I checked the layering, because I've had the same problem with the player. Any idea how to fix it?
This is the level load function
function stage1() {
Game.add.image(0, 0, 'background');
map1 = Game.add.tilemap('level1');
map1.addTilesetImage('32x32_tileset_mario', 'tileset');
map1.setCollisionByExclusion([]);
ground = map1.createLayer(0);
// layer1 = map1.createLayer(1)
// map1.setTileIndexCallback(392, pK1);
enemyCreate();
player = Game.add.sprite(200, 800, 'player');
player.anchor.setTo(0.5);
player.scale.setTo(0.4);
player.animations.add('fly', [0, 1, 2], 10, true);
Game.physics.enable(player);
player.body.collideWorldBounds = true;
player.body.gravity.y = 600;
console.log('stage 1');
}
and this is the function to create the enemies.
function enemyCreate() {
for (let i = 0; i < 3; i++) {
NPC.create(x + 1300, 1940, 'player');
x += 200;
NPC.scale.setTo(0.4);
// NPC.body.immovable = true
}
}
Any idea how to fix this issue?
Here's the full code - https://pastebin.com/ZM2Sg2Aa