Jump to content

Call functon in Game state from the DOM


ptotheaul
 Share

Recommended Posts

I need to call to call a function in my game state from the Dom to toggle the audio of my game.  Is this possible?

 

In index.html the game is set up like this:

//////// index.html /////////////////////////////////////////////////////////////////////////

var game;
            (function() {
                game = new Phaser.Game(640, 1195, Phaser.CANVAS, 'the-game');

                game.state.add("Boot",boot);
                game.state.add("Preload",preload);
                game.state.add("TheGame",theGame);
       
                game.state.start("Boot");

            })();

///////////////////////////////////////////////////////////////////////////////////////////////

 

After preload

this.game.state.start("TheGame");

is called to load the game.  The function I need to call from a button in the DOM is funcFromDom

///////////////////////////////////////////////////////////////////////////////////////////////

var theGame = function(game){
 
};

theGame.prototype = {
      create: function(){
          console.log("create()")

},

 funcFromDom: function(){
          console.log("called from the dom");

},

}

 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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