State ID (see constants)
Instantiated Stage to associate with state ID
Optional
start: boolean = falseif true the state will be changed immediately after adding it.
set
state
class MenuButton extends me.GUI_Object {
onClick() {
// Change to the PLAY state when the button is clicked
me.state.change(me.state.PLAY);
return true;
}
};
class MenuScreen extends me.Stage {
onResetEvent() {
// 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() {
// Stop music
me.audio.stopTrack();
}
};
me.state.set(me.state.MENU, new MenuScreen());
associate the specified state with a Stage