In my game I am trying to use one of my variables I have initiated in my create function outside of that scope and to be used in the update function. Ideally my code would look like this:
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 with this however is that I can not access next1 to collide with my player character "faune" since the error given is that I "Cannot find name 'Next1'.". If anyone has any idea how to use this across functions with Phaser that would be extremely helpful.
Thanks, arthur