MathGames Methods - TeachMeInc/MathGames-SDK GitHub Wiki


General Overview
MathGames Methods
Events
Using QuestionPanel

Initialization

connect

Success event: MathGamesEvent.CONNECTED
MathGames.instance.connect (
    container:DisplayObjectContainer,
      // This will be the parent of the MathGames panels.
    config:Object
      // A collection of parameters used to set up the question engine.
) :void

The provided container must be attached to the stage when connect is invoked. Valid options for configuration are as follows:

var configuration:Object = {
    "api_key": "528e1abeb4967cb32b00028e",
      // (REQUIRED) Specifies the API Key used to access the question service.
    "pool_key": "LEVEL_ONE",
      // (REQUIRED) Specifies the desired default question pool.
    "log_func": trace
      // (OPTIONAL) A function expecting a string which will be invoked with
      // debug messages.
}

selectSkill

Success event: MathGamesEvent.SKILL_SELECTED
User cancel event: MathGamesEvent.SKILL_SELECT_CANCELLED
MathGames.instance.selectSkill () :void

Opens the Skill Select panel to allow the player to select a skill. This must be called before any calls to startSession.

Session Management

A game using the MathGames service consists of a series of play sessions where questions are presented to the player one after the other. Play sessions happen between a call to startSession and a call to endSession. During the session, QUESTION_READY events are fired. Once the player has reached a milestone, such as completing a level, endSession should be called, and showProgress may be invoked to get some summary information about the player's progress.

startSession

Success event: MathGamesEvent.SESSION_READY
MathGames.instance.startSession (
    config:Object
      // A collection of parameters used to configure the next play session.
) :void

This method accepts a configuration object, and a callback function which is invoked when the questions are ready and the gameplay session can begin.

Valid options for configuration are as follows:

var configuration:Object = {
    "pool_key": "LEVEL_ONE",
      // (OPTIONAL) Specifies the desired question pool to use for this session.
      // If none is provided then the previously specified one is used.
    "clear_progress": true,
      // (OPTIONAL) Clears accumulated progress which is viewed in the
      // showProgress screen.
}

endSession

MathGames.instance.endSession () :void

This method accepts no parameters and returns nothing. You can assume that, immediately after calling endSession, the session is complete. You can then show menus, cutscenes, or anything related to the game which is not part of the question-answering sessions.

showProgress

Panel closed event: MathGamesEvent.PROGRESS_CLOSED
MathGames.instance.showProgress () :void

The showProgress method pops up a summary panel showing the progressions and skills which the player has accumulated since the previous call to showProgress. It should be called when the player reaches a milestone in the game, such as completing a level, and it's appropriate to show some summarizing information about the player's progress so far.

Miscellaneous

showSupportedSkillStandards

MathGames.instance.showSupportedSkillStandards () :void

Displays a list of all curriculum mappings supported by the MathGames SDK, and highlights the ones supported by the current game. Currently does not fire an event when closed since it's typically invoked from the main menu where nothing behind the panel is time-critical.

postMetrics

MathGames.instance.postMetrics (
    key:String,
    data:Object
) :void

Post custom metrics events to the MathGames servers. You can track these events from your developer dashboard on mathgames.com.

setSoundEnabled

MathGames.instance.setSoundEnabled (
    enabled:Boolean
) :void

Toggles built-in sounds in the MathGames SDK screens and popups.

moreMathGames

MathGames.instance.moreMathGames () :void

Opens MathGames.com in a browser.