Game Class
整個遊戲(多個Level)的主體 主要功能為新增移除關卡與關卡的切換
Item Index
Methods
- addNewLevel static
- exitFullScreen static
- fullScreen static
- goToLevel static
- goToNextLevel static
- goToPreviousLevel static
- start static
Methods
addNewLevel
(
static
-
levelData
加入一個新的關卡
Parameters:
-
levelData
Object{ 關卡名稱: 關卡的instance }
Example:
Framework.Game.addNewLevel({menu: new MyMenu()}); //MyMen繼承自Level
exitFullScreen
()
static
退出全螢幕
Example:
Framework.Game.exitFullScreen();
fullScreen
(
static
-
ele
讓任何一個在網頁上的元件得以全螢幕, 一定要在有使用者可以觸發的事件內撰寫, 例如: click, mousedown, mouseup, mousemove, touchstart, touchmove, keydown, keyup 否則會無法全螢幕
Parameters:
-
ele
Object要被全螢幕的DOM, 若不設定則為遊戲的CANVAS
Example:
Framework.Game.fullScreen();
goToLevel
(
static
-
levelName
前往另一個關卡(前後皆可), 若沒有該關卡, 會throw exception
Parameters:
-
levelName
Object關卡名稱
Example:
Framework.Game.goToLevel('menu');
goToNextLevel
()
static
前往下一個關卡, 若沒有下一個關卡, 會throw exception
Example:
Framework.Game.goToNextLevel();
goToPreviousLevel
()
static
前往前一個關卡, 若沒有前一個關卡, 會throw exception
Example:
Framework.Game.goToPreviousLevel();
start
()
static
讓遊戲開始執行
Example:
Framework.Game.start();