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

Calling a function from another file


Fedia
 Share

Recommended Posts

How to call a function correctly checkDown ? Now it shows an error that this function was not found.

main.js

function checkDown() {
    if (CAN_CLICK) {
        CAN_CLICK = false;
        last_pointer_position.x = game.input.activePointer.worldX;
        last_pointer_position.y = game.input.activePointer.worldY;

        setTimeout(function () {
            CAN_CLICK = true;
        }, 200)
    }
};
game = new Phaser.Game(_GLOBAL.Width, _GLOBAL.Height, Phaser.CANVAS, 'game');

game.state.add('menu', gameCreate);
game.state.start('menu');

gameCreate.js

var gameCreate = {
    preload: function () {
    }

    create: function() {
        var self = this;
        this.game.input.onDown.add(self.checkDown, this);
    }

 

Link to comment
Share on other sites

  • 2 weeks later...
 Share

  • Recently Browsing   0 members

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