Jump to content

How to access StateManager from anywhere?


bymafmaf
 Share

Recommended Posts

I have this function in my Kare.StartMenu.prototype

enterLobby: function (pointer) {        Kare.socket = io.connect(Kare.serverUrl);        Kare.socket.emit('sendDeviceID', Kare.deviceID);        Kare.socket.emit('matchUsers');        Kare.socket.on('usersMatched', function(){            this.state.startGame();        });    }

Normally, states have "state" property as StateManager so that we can call it as this.state. However, here I use socket.io and in Kare.socket.on() function, "this" becomes socket object so this.state is undefined. I tried several tricks but they didn't help.

 

How can I start my game? :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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