For example:
function create() {
function hello() {
console.log('hello')
}
}
function update() {
hello()
}
The Chrome console shows ‘hello is not defined’
For example:
function create() {
function hello() {
console.log('hello')
}
}
function update() {
hello()
}
The Chrome console shows ‘hello is not defined’
What you define inside a function is not visible from outside the function.
You can make a class that inherits from Phaser.Scene and add whatever methods you need:
class MyScene extends Phaser.Scene {
constructor(name) { super(name); }
create() { }
update() { this.hello(); }
hello() { console.log('hello'); }
}
Or you can define it beside the others:
function create() {
}
function update() {
// RIP console
hello();
}
function hello() {
console.log('hello')
}