Cocos Creator API

1.3.0

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

Game

: cc

cc.game is the singleton object for game related functions.

EVENT_HIDE String

Event triggered when game hide to background. Please note that this event is not 100% guaranteed to be fired.

:

cc.game.on(cc.game.EVENT_HIDE, function () {
    cc.audioEngine.pauseMusic();
    cc.audioEngine.pauseAllEffects();
});

EVENT_SHOW String

Event triggered when game back to foreground Please note that this event is not 100% guaranteed to be fired.

EVENT_GAME_INITED String

Event triggered after game inited, at this point all engine objects and game scripts are loaded

EVENT_RENDERER_INITED String

Event triggered after renderer inited, at this point you will be able to use the render context

CONFIG_KEY Object

Key of config

frame Object

The outer frame of the game canvas, parent of cc.container.

container Object

The container of game canvas, equals to cc.container.

canvas Object

The canvas of the game, equals to cc._canvas.

config Object

The current game configuration, including:

  1. debugMode
    "debugMode" possible values :
    0 - No message will be printed.
    1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
    2 - cc.error, cc.assert, cc.warn will print in console.
    3 - cc.error, cc.assert will print in console.
    4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
    5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
    6 - cc.error, cc.assert will print on canvas, available only on web.
  2. showFPS
    Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
  3. frameRate
    "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
  4. id
    "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
  5. renderMode
    "renderMode" sets the renderer type, only useful on web :
    0 - Automatically chosen by engine
    1 - Forced to use canvas renderer
    2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
  6. scenes
    "scenes" include available scenes in the current bundle.

    Please DO NOT modify this object directly, it won't have any effect.

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

onStart ( )

Callback when the scripts of engine have been load.

onStop ( )

Callback when game exits.

setFrameRate
(
  • frameRate
)

Set frameRate of game.

frameRate Number

step ( )

Run the game frame by frame.

pause ( )

Pause the game main loop. This will pause: game logic execution, rendering process, event manager, background music and all audio effects. This is different with cc.director.pause which only pause the game logic execution.

resume ( )

Resume the game from pause. This will resume: game logic execution, rendering process, event manager, background music and all audio effects.

isPaused ( ) Boolean

Check whether the game is paused.

:

restart ( )

Restart game.

end ( )

End game, it will close the game window

prepare
(
  • cb
)

Prepare game.

run
(
  • [config ]
  • [onStart ]
)

Run game with configuration object and onStart function.

config optional Object | Function

Pass configuration object or onStart function

onStart optional Function

function to be executed after game initialized

addPersistRootNode
(
  • node
)

Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.
The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect.

node Node

The node to be made persistent

removePersistRootNode
(
  • node
)

Remove a persistent root node.

node Node

The node to be removed from persistent node list

isPersistRootNode
(
  • node
)
Boolean

Check whether the node is a persistent root node.

node Node

The node to be checked

:

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index