Jump to content

Update Function in State Does Not Recognise When I Change a Value it is Checking!


Punchausen
 Share

Recommended Posts

Hi folks,

This has me stumped..  I have a variable I have defined for a state called 'loginProgression' 

var login = function(game) {

    var promptText,
        username,
        lockInNameButton,
        loginProgression,
        planet = [];
}

The purpose of this is that depending on what I've done in the login process (entering a name, choosing an object), it will fire off the new fields.  Here's the update function:

update: function () {

        console.log('Login progression is ' + this.loginProgression);

        switch (this.loginProgression) {

            case 0:
                this.requestName();
                break;
            case 2:
                this.requestPlanet();
                break;
            case 4:
                console.log("Shouldnt see this");
                break;
            default:
                break;
        }
    }

 

This thing that is confusing me is that once you submit your name, it updates the 'loginProgression' value to 2 - but the console log in 'update' still repeats that it is 1.  Checking the variable in the chrome console also shows it to be correctly updated to 2 - so it's as if the 'update' function somehow doesn't notice when a global it's checking constantly changes!

 

Any help on this is much appreciated!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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