Namespace: state

me. state

a State Manager (state machine)

There is no constructor function for me.state.

Source:
state.js, line 105

Members

<static, constant> CREDITS

default state ID for Credits Screen
Source:
state.js, line 306

<static, constant> GAME_END

default state ID for Game End Screen
Source:
state.js, line 290

<static, constant> GAMEOVER

default state ID for Game Over Screen
Source:
state.js, line 282

<static, constant> LOADING

default state ID for Loading Screen
Source:
state.js, line 250
default state ID for Menu Screen
Source:
state.js, line 258

<static, constant> PLAY

default state ID for Play Screen
Source:
state.js, line 274

<static, constant> READY

default state ID for "Ready" Screen
Source:
state.js, line 266

<static, constant> SCORE

default state ID for High Score Screen
Source:
state.js, line 298

<static, constant> SETTINGS

default state ID for Settings Screen
Source:
state.js, line 314

<static, constant> USER

default state ID for user defined constants
Source:
state.js, line 322
Example
var STATE_INFO = me.state.USER + 0;
var STATE_WARN = me.state.USER + 1;
var STATE_ERROR = me.state.USER + 2;
var STATE_CUTSCENE = me.state.USER + 3;

Methods

<static> change(state)

change the game/app state
Parameters:
Name Type Argument Description
state Number State ID (see constants)
arguments... <optional>
extra arguments to be passed to the reset functions
Source:
state.js, line 618
Example
// The onResetEvent method on the play screen will receive two args:
// "level_1" and the number 3
me.state.change(me.state.PLAY, "level_1", 3);

<static> current() → {me.ScreenObject}

return a reference to the current screen object
useful to call a object specific method
Source:
state.js, line 575
Returns:
Type
me.ScreenObject

<static> isCurrent(state)

return true if the specified state is the current one
Parameters:
Name Type Description
state Number State ID (see constants)
Source:
state.js, line 670

<static> isPaused() → {Boolean}

Return the pause state of the state manager
Source:
state.js, line 508
Returns:
true if the game is paused
Type
Boolean

<static> isRunning() → {Boolean}

return the running state of the state manager
Source:
state.js, line 496
Returns:
true if a "process is running"
Type
Boolean

<static> onPause()

onPause callback
Source:
state.js, line 335

<static> onRestart()

onRestart callback
Source:
state.js, line 359

<static> onResume()

onResume callback
Source:
state.js, line 343

<static> onStop()

onStop callback
Source:
state.js, line 351

<static> pause(pauseTrack)

pause the current screen object
Parameters:
Name Type Description
pauseTrack Boolean pause current track on screen pause
Source:
state.js, line 405

<static> restart(resumeTrack)

Restart the screen object from a full stop.
Parameters:
Name Type Description
resumeTrack Boolean resume current track on screen resume
Source:
state.js, line 435

<static> resume(resumeTrack)

resume the screen object
Parameters:
Name Type Description
resumeTrack Boolean resume current track on screen resume
Source:
state.js, line 467

<static> set(state, so)

associate the specified state with a screen object
Parameters:
Name Type Description
state Number State ID (see constants)
so me.ScreenObject Instantiated ScreenObject to associate with state ID
Source:
state.js, line 520
Example
var MenuButton = me.GUI_Object.extend({
    "onClick" : function () {
        // Change to the PLAY state when the button is clicked
        me.state.change(me.state.PLAY);
        return true;
    }
});

var MenuScreen = me.ScreenObject.extend({
    onResetEvent: function() {
        // Load background image
        me.game.world.addChild(
            new me.ImageLayer(0, 0, {
                image : "bg",
                z: 0 // z-index
            }
        );

        // Add a button
        me.game.world.addChild(
            new MenuButton(350, 200, { "image" : "start" }),
            1 // z-index
        );

        // Play music
        me.audio.playTrack("menu");
    },

    "onDestroyEvent" : function () {
        // Stop music
        me.audio.stopTrack();
    }
});

me.state.set(me.state.MENU, new MenuScreen());

<static> setTransition(state, enable)

enable/disable transition for a specific state (by default enabled for all)
Parameters:
Name Type Description
state Number State ID (see constants)
enable Boolean
Source:
state.js, line 605

<static> stop(pauseTrack)

Stop the current screen object.
Parameters:
Name Type Description
pauseTrack Boolean pause current track on screen stop.
Source:
state.js, line 375

<static> transition(effect, color, duration)

specify a global transition effect
Parameters:
Name Type Argument Default Description
effect String (only "fade" is supported for now)
color me.Color | String a CSS color value
duration Number <optional>
1000 expressed in milliseconds
Source:
state.js, line 588
Copyright © 2011 - 2017, Olivier Biot, Jason Oster, Aaron McLeod
Documentation generated by JSDoc 3.4.0 on 2017-02-28T11:37:41+08:00 using the DocStrap template modified by codename-.