Sign in to follow this  

Using Prototype to call a function (method)

Recommended Posts


I'm reading this tutorial (2nd part) :

in the second exemple, we got something like :

class SimpleGame {

    constructor() { = new Phaser.Game(640, 480, Phaser.AUTO, 'content', {
            create: this.create});}

    moveUp(e: KeyboardEvent) {
            this.jetSprite.position.add(0, -1);

    create() {
        this.W.onDown.add(SimpleGame.prototype.moveUp, this);

can someone tell me why we need to use SimpleGame.prototype.moveUp to call this method? (and not just this.moveUP ?) 

is this because we are using this context ?


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.