I'm facing an issue in my game where I can't access a variable that I declared in the create function when trying to use it in the update function. Here is a snippet of what I'm trying to achieve:
create()
{
const map = this.make.tilemap({ key: 'mainmap' })
const tileset = map.addTilesetImage('Serene_Village_16x16', 'tiles', 16, 16, 1, 2)
const Next1 = map.createLayer('Next', tileset)
update(t: number, dt: number){
this.physics.world.collide(this.faune, Next1, ()=>{
console.log("testing")
this.scene.stop(),
this.scene.start('secondmap');
});
The problem here is that I'm unable to access 'Next1' in order to use it for collision detection with my player character "faune". The error message I get says "Cannot find name 'Next1'. If anyone has any suggestions on how to deal with this situation in Phaser, I would greatly appreciate it.
Thanks, arthur