Can I use JS ES6 arrow functions in Phaser?

Hi! I am new to Phaser. I was trying to use arrow functions to create a sprite then add it to the scene object but it did not work.
Eg: const create = () => {…} -> Did not work
function create() {…} -> Worked!

Can someone tell me if arrow functions are usable in Phaser ? Appreciate!

the arrow functions don’t have a this so I’m guessing this.add.image() and similar did not work?

Thanks! Really appreciate!

1 Like