The event which will be triggered after the rendering process.
The event which will be triggered after the physics process.
物理过程之后所触发的事件。
The event which will be triggered after launching a new scene.
The event which will be triggered after engine and components update logic.
The event which will be triggered before the rendering process.
The event which will be triggered before the physics process.
物理过程之前所触发的事件。
The event which will be triggered before launching a new scene.
The event which will be triggered before loading a new scene.
The event which will be triggered at the beginning of every frame.
The event which will be triggered when the singleton of Director initialized.
The event which will be triggered when the singleton of Director reset.
Loads the scene by its uuid.
场景资源的 uuid。
仅加载和初始化场景,但并不运行。此参数仅在编辑器环境中生效。
Calculates delta time since last time it was called, the result is saved to an internal property.
Trigger an event directly with the event name and necessary arguments.
event type
End the life of director in the next frame
Returns the FPS value. Please use Game.setFrameRate to control animation interval.
Returns the AnimationManager
associated with this director. Please use getSystem(AnimationManager.ID)
Returns the current time.
Returns the delta time since last frame.
Returns current logic Scene.
Returns current logic Scene.
Returns the scheduler associated with this director.
get a system.
Returns how many frames were called since the director started.
Returns the size of the WebGL view in points.
It takes into account any possible rotation (device orientation) of the window.
Returns the size of the OpenGL view in pixels.
It takes into account any possible rotation (device orientation) of the window.
On Mac winSize and winSizeInPixels return the same value.
(The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use view.getFrameSize()
)
Checks whether there is correspond event listener registered on the given event.
Event type.
Callback function when event triggered.
Callback callee.
Returns whether or not the Director is paused.
Loads the scene by its name.
The name of the scene to load.
callback, will be called after scene launched.
if error, return false
Run main loop of director
Removes the listeners previously registered with the same type, callback, target and or useCapture, if only type is passed as parameter, all listeners registered with that type will be removed.
A string representing the event type being removed.
The callback to remove.
Register an callback of a specific event type on the EventTarget.
This type of event should be triggered via emit
.
A string representing the event type to listen for.
The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).
The target (this object) to invoke the callback, can be null
Register an callback of a specific event type on the EventTarget, the callback will remove itself after the first time it is triggered.
A string representing the event type to listen for.
The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).
Pause the director's ticker, only involve the game logic execution.
It won't pause the rendering process nor the event manager.
If you want to pause the entire game including rendering, audio and event,
please use game.pause
.
Pre-loads the scene to reduces loading time. You can call this method at any time you want.
After calling this method, you still need to launch the scene by director.loadScene
.
It will be totally fine to call director.loadScene
at any time even if the preloading is not
yet finished, the scene will be launched after loaded automatically.
场景名称。
加载回调。
Pre-loads the scene to reduces loading time. You can call this method at any time you want.
After calling this method, you still need to launch the scene by director.loadScene
.
It will be totally fine to call director.loadScene
at any time even if the preloading is not
yet finished, the scene will be launched after loaded automatically.
场景名称。
加载进度回调。
加载回调。
Removes cached all cocos2d cached data.
Purge the director
itself, including unschedule all schedule,
remove all event listeners, clean up and exit the running scene, stops all animations, clear cached data.
Register a system.
Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
The event type or target with which the listeners will be removed
Reset the director, can be used to restart the director after purge
Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
Run a scene. Replaces the running scene with a new one or enter the first scene.
The new scene will be launched at the end of the current frame.
The need run scene.
The function invoked at the scene before loading.
The function invoked at the scene after launch.
Run a scene. Replaces the running scene with a new one or enter the first scene.
The new scene will be launched immediately.
The need run scene.
The function invoked at the scene before loading.
The function invoked at the scene after launch.
Sets animation interval, this doesn't control the main loop.
To control the game's frame rate overall, please use game.setFrameRate
The animation interval desired.
Set color for clear screen.
(Implementation can be found in directorCanvas.js/directorWebGL.js)
Enables or disables WebGL depth test.
Implementation can be found in directorCanvas.js/directorWebGL.js
Sets the scheduler associated with this director.
Starts Animation
Stops animation
Removes all callbacks previously registered with the same target (passed as parameter). This is not for removing all listeners in the current event target, and this is not for removing all listeners the target parameter have registered. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
The target to be searched for all related listeners
Generated using TypeDoc
ATTENTION: USE `director` INSTEAD OF `Director`.
`director` is a singleton object which manage your game's logic flow.
Since the `director` is a singleton, you don't need to call any constructor or create functions,
the standard way to use it is by calling:
- `director.methodName();`
It creates and handle the main Window and manages how and when to execute the Scenes.
The
director
is also responsible for:- initializing the OpenGL context
- setting the OpenGL pixel format (default on is RGB565)
- setting the OpenGL buffer depth (default on is 0-bit)
- setting the color for clear screen (default one is BLACK)
- setting the projection (default one is 3D)
- setting the orientation (default one is Portrait)
The
director
also sets the default OpenGL context:- GL_TEXTURE_2D is enabled
- GL_VERTEX_ARRAY is enabled
- GL_COLOR_ARRAY is enabled
- GL_TEXTURE_COORD_ARRAY is enabled
`director` also synchronizes timers with the refresh rate of the display.
Features and Limitations:
- Scheduled timers & drawing are synchronizes with the refresh rate of the display
- Only supports animation intervals of 1/60 1/30 & 1/15