qc.Game

Description

This is the heart of the game, which provides a large part of fast functional access channel. The instance of qc.Game is automatically constructed by editor.

Prototype

  • qc.Game(width, height, parent, state, transparent, editor, debug, physicsConfig);
  • qc.Game(config);

The game instance does not need to be created manually. It will be automatically in StartGame.html that is created when release game. The following sample code for StartGame.html

        qici.loadGame = function() {
        var game = window[qici.config.gameInstance] = new qc.Game({
            width: '100%',
            height: '100%',
            parent: 'gameDiv',
            state: qici.splashState,
            editor: qici.config.editor === true,
            backgroundColor: new qc.Color(qici.config.backgroundColor),
            runInBackground: qici.config.runInBackground,
            antialias: qici.config.antialias,
            resolution : qici.config.resolution,
            transparent: qici.config.transparent,
            debug: qici.config.developerMode === true,
            renderer: (function() {
                if (qici.config.renderer === 'WebGL') {
                    return Phaser.WEBGL;
                }
                if (qici.config.renderer === 'Canvas'){
                    return Phaser.CANVAS;
                }
                return Phaser.AUTO;
            })()
        });

        game.loadingProcessCallback = qici.loadAssetsNotify;
        game.bundleIdentifier = qici.config.bundleIdentifier;
        game.log.important('**** [QICI Engine]Starting game: {0}', qici.config.gameName);
    };

\qici.config_ variable is also defined in StartGame.html. gameInstance variable is 'game' by default. User can configure the game instance name in the editor project settings. When using the default 'game' name, you can use the global game variable to refer to the instance of qc.Game.

Varibles

Variable name Description
log: qc.Log Read only. Log Management
debug: qc.Debug Read only. Debug Management
device: qc.Device Read only. Device Information
add: qc.GameObjectFactory Read only. Objects Factory
input: qc.Input Read only. Input Management
plugins: qc.PluginManager Read only. Plugins Management
math: qc.Math2 Read only. Math Library
timer: qc.Timer Read only.Timer
time: qc.Time Read only.Time
sound: qc.SoundManager Read only.Sound Manager
assets: qc.Assets Read only. Assets Management
stage: qc.Stage Read only. Stage
world: qc.World Read only. Game World
gs: qc.GS Read only. The connector of game server
state: qc.StateManager Obsolete.
scene: qc.SceneManager Read only. Scenes Management
serializer: qc.Serializer Read only. Serializer
nodePool: qc.NodePool Read only. NodePool
storage: qc.Storage Read only. Local Storage Management
canvas: Phaser.Canvas Read only.
width: int The width of game world. Unit:px
height: int The height of game world. Unit:px
transparent: boolean true: the game background is transparent.
antialias: boolean Draw all image textures anti-aliased or not.
isBooted: boolean Read only. true: the game is booted
isRunning: boolean Read only. true: the game is running.
paused: boolean true: the game is paused.
config: object Configuration information of the game.
physicsConfig: object Physics config information of the game.

Events

Event name Description
onStart When the game is started, this event is triggered.
onPause When the game is paused, this event is triggered.
onResume When resuming the game, this event is triggered.
onBlur When the game loses the focus, this event is triggered.
onFocus When the game receives the focus, this event is triggered.

Mehtods

Method Description
shutdown Shut down the game.