Using ‘this’ in custom Phaser classes

  Kiến thức lập trình

I’m working on an old school RPG using Phaser.js. I have what I know is a simple question. In my custom classes almost all have:

export default class Chest extends Phaser.Physics.Arcade.Sprite{
  constructor(scene, x, y, name, description) {
        super(scene, x, y, 'treasure');
        this.scene = scene;

Should I be using this.scene or omit it and just use scene? I’m certai there’s a difference, but I don’t know what the pros/cons are of each.

1

LEAVE A COMMENT