Jump to content

How to access StateManager from anywhere?


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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