Create a function in create () and run it in update ()

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'); }
}
1 Like

Or you can define it beside the others:

function create() {
}

function update() {
    // RIP console
    hello();
}

function hello() {
    console.log('hello')
}
1 Like