A
A
Alexey2017-06-05 11:12:50
typescript
Alexey, 2017-06-05 11:12:50

How to access inside a class from its method in Typescript?

Situation:
Inside the Main class there is an update method.
From the update method I call the win class method.

export class Main {
   update {
      this.game.physics.arcade.overlap(this._Players[0].PhaserPlayer, this._Gorilla.Goal, this.win);
   },
   win {
      ...
   }
}

Question :
Inside win, I need access to a class, for example via this, but I only see the local scope of this function:
function () {
        this.game.state.start('Main');
}

How can I access the class inside win?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2017-06-05
@azovl

public win = () => {
this.game.state.start('Main');
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question