Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Access an instance of a class


Corsair
 Share

Recommended Posts

 

How can I access an instance of a class outside the class?

class World extends Phaser.Scene {
    constructor() {
        super({
            key: 'World'
        });
    }

    preload() {
        this.load.image('grass','images/world/tiles/grass.png');
    }

    create (){
        this.img = this.add.image(100,100,'grass');

        this.input.on('pointermove', (pointer) => {

            this.img.x = pointer.x;
            this.img.y = pointer.y;

        });

    }

}

How i can access to 'this.img' outside World class?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...