⚠️ This documentation corresponds to the latest development branch of axmol. It might diverge from the official releases.
|
Axmol Engine 3.0.0-ff0e11a
|
Class that creates and handles the main Window and manages how and when to execute the Scenes. More...
#include <Director.h>
Public Types | |
| enum class | Projection { _2D , _3D , CUSTOM , DEFAULT = _3D } |
| Possible projection types used by the director. More... | |
Public Member Functions | |
| ~Director () | |
| @lua NA | |
| Scene * | getRunningScene () |
| Gets the current running Scene. | |
| Scene * | getNextScene () |
| Gets the top(next) scene which will going to running state. | |
| float | getAnimationInterval () |
| Gets the FPS value. | |
| void | setAnimationInterval (float interval) |
| Sets the FPS value. | |
| bool | isStatsDisplay () |
| Whether the FPS on the bottom-left corner of the screen is displayed or not. | |
| void | setStatsDisplay (bool displayStats) |
| Display the FPS on the bottom-left corner of the screen. | |
| float | getSecondsPerFrame () |
| Gets the seconds per frame. | |
| void | setStatsAnchor (AnchorPreset anchor=(AnchorPreset) 0) |
| Sets the stats corner displayed on screen if display stats is enabled. | |
| RenderView * | getRenderView () |
| Sets the FPS value. | |
| void | setRenderView (RenderView *renderView) |
| Sets the RenderView. | |
| bool | isNextDeltaTimeZero () |
| Whether or not _nextDeltaTimeZero is set to 0. | |
| void | setNextDeltaTimeZero (bool nextDeltaTimeZero) |
| Sets the delta time between current frame and next frame is 0. | |
| bool | isPaused () |
| Whether or not the Director is paused. | |
| unsigned int | getTotalFrames () |
| How many frames were called since the director started. | |
| Projection | getProjection () |
| Gets an projection. | |
| void | setProjection (Projection projection) |
| Sets projection. | |
| void | setViewport () |
| Sets the viewport. | |
| bool | isSendCleanupToScene () |
| Whether or not the replaced scene will receive the cleanup message. | |
| Node * | getNotificationNode () const |
| This object will be visited after the main scene is visited. | |
| void | setNotificationNode (Node *node) |
| Sets the notification node. | |
| const Vec2 & | getCanvasSize () const |
| Returns the size of the render view in points. | |
| Vec2 | getCanvasSizeInPixels () const |
| Returns the size of the render view in pixels. | |
| Vec2 | getVisibleSize () const |
| Returns visible size of the render view in points. | |
| Vec2 | getVisibleOrigin () const |
| Returns visible origin coordinate of the render view in points. | |
| Rect | getSafeAreaRect () const |
| Returns safe area rectangle of the render view in points. | |
| Vec2 | screenToWorld (const Vec2 &point) |
| Converts a point from screen coordinates to the rendering coordinate system. | |
| Vec2 | worldToScreen (const Vec2 &point) |
| Converts an rendering coordinate to a screen coordinate. | |
| float | getZEye () const |
| Gets the distance between camera and near clipping frame. | |
| void | runWithScene (Scene *scene) |
| Enters the Director's main loop with the given Scene. | |
| void | pushScene (Scene *scene) |
| Suspends the execution of the running scene, pushing it on the stack of suspended scenes. | |
| void | popScene () |
| Pops out a scene from the stack. | |
| void | popToRootScene () |
| Pops out all scenes from the stack until the root scene in the queue. | |
| void | popToSceneStackLevel (int level) |
| Pops out all scenes from the stack until it reaches level. | |
| void | replaceScene (Scene *scene) |
| Replaces the running scene with a new one. | |
| Scene * | popPreviousSceneOut () |
| Removes the previous scene from the stack if it exists, and returns it If there are less than 2 scenes in the stack, or if there is a scene switch about to occur, then this call would be invalid, and a nullptr will be returned. | |
| void | end () |
| Ends the execution, releases the running scene. | |
| void | pause () |
| Pauses the running scene. | |
| void | resume () |
| Resumes the paused scene. | |
| void | stopAnimation () |
| Stops the animation. | |
| void | startAnimation () |
| The main loop is triggered again. | |
| void | drawScene () |
| Draw the scene. | |
| void | purgeCachedData () |
| Removes all axmol cached data. | |
| void | setDefaultValues () |
| Sets the default values based on the Environment info. | |
| void | setRenderDefaults () |
| Sets the Render default values. | |
| void | setClearColor (const Color &clearColor) |
| Sets clear values for the color buffers, value range of each element is [0.0, 1.0]. | |
| void | renderFrame (float dt) |
| Invoke render frame with delta time. | |
| void | setContentScaleFactor (float scaleFactor) |
| The size in pixels of the surface. | |
| float | getContentScaleFactor () const |
| Gets content scale factor. | |
| JobSystem * | getJobSystem () const |
| Gets the JobSystem associated with this director. | |
| Scheduler * | getScheduler () const |
| Gets the Scheduler associated with this director. | |
| void | setScheduler (Scheduler *scheduler) |
| Sets the Scheduler associated with this director. | |
| ActionManager * | getActionManager () const |
| Gets the ActionManager associated with this director. | |
| void | setActionManager (ActionManager *actionManager) |
| Sets the ActionManager associated with this director. | |
| EventDispatcher * | getEventDispatcher () const |
| Gets the EventDispatcher associated with this director. | |
| void | setEventDispatcher (EventDispatcher *dispatcher) |
| Sets the EventDispatcher associated with this director. | |
| Renderer * | getRenderer () const |
| Returns the Renderer associated with this director. | |
| float | getFrameRate () const |
| Gets Frame Rate. | |
| void | pushMatrix (MATRIX_STACK_TYPE type) |
| Clones a specified type matrix and put it to the top of specified type of matrix stack. | |
| void | popMatrix (MATRIX_STACK_TYPE type) |
| Pops the top matrix of the specified type of matrix stack. | |
| void | loadIdentityMatrix (MATRIX_STACK_TYPE type) |
| Adds an identity matrix to the top of specified type of matrix stack. | |
| void | loadMatrix (MATRIX_STACK_TYPE type, const Mat4 &mat) |
| Adds a matrix to the top of specified type of matrix stack. | |
| void | multiplyMatrix (MATRIX_STACK_TYPE type, const Mat4 &mat) |
| Multiplies a matrix to the top of specified type of matrix stack. | |
| const Mat4 & | getMatrix (MATRIX_STACK_TYPE type) const |
| Gets the top matrix of specified type of matrix stack. | |
| void | resetMatrixStack () |
| Clear all types of matrix stack, and add identity matrix to these matrix stacks. | |
| const std::thread::id & | getCocos2dThreadId () const |
| returns the axmol thread id. | |
| void | setChildrenIndexerEnabled (bool enable) |
| Enable node tree children indexer map, the concept is like database INDEX Notes: If enable is true: will cost more memory to speed up getChildByTag & getChildByName. | |
| bool | isChildrenIndexerEnabled () const |
| returns whether or not node tree children indexer map enabled | |
| void | queueOperation (AsyncOperation op, void *param=nullptr) |
| since Axmol-1.0 queue a priority operation in render thread, even through app in background | |
| bool | isValid () const |
| returns whether or not the Director is in a valid state | |
Static Public Member Functions | |
| static Director * | getInstance () |
| Returns a shared instance of the director. | |
Static Public Attributes | |
| static const char * | EVENT_BEFORE_SET_NEXT_SCENE |
| Director will trigger an event before set next scene. | |
| static const char * | EVENT_AFTER_SET_NEXT_SCENE |
| Director will trigger an event after set next scene. | |
| static const char * | EVENT_PROJECTION_CHANGED |
| Director will trigger an event when projection type is changed. | |
| static const char * | EVENT_BEFORE_UPDATE |
| Director will trigger an event before Schedule::update() is invoked. | |
| static const char * | EVENT_AFTER_UPDATE |
| Director will trigger an event after Schedule::update() is invoked. | |
| static const char * | EVENT_AFTER_VISIT |
| Director will trigger an event after Scene::render() is invoked. | |
| static const char * | EVENT_AFTER_DRAW |
| Director will trigger an event after a scene is drawn, the data is sent to GPU. | |
| static const char * | EVENT_BEFORE_DRAW |
| Director will trigger an event before a scene is drawn, right after clear. | |
| static const char * | EVENT_RESET |
| Director will trigger an event while resetting Director. | |
| static const char * | EVENT_DESTROY |
| Director will trigger an event while destroying Director. | |
Class that creates and handles the main Window and manages how and when to execute the Scenes.
The Director is also responsible for:
Since the Director is a singleton, the standard way to use it is by calling: _ Director::getInstance()->methodName();
|
strong |
|
inline |
| void setAnimationInterval | ( | float | interval | ) |
Sets the FPS value.
FPS = 1/interval.
|
inline |
Sets the FPS value.
Get the RenderView. @lua NA
| void setRenderView | ( | RenderView * | renderView | ) |
Sets the RenderView.
@lua NA
| void setNextDeltaTimeZero | ( | bool | nextDeltaTimeZero | ) |
Sets the delta time between current frame and next frame is 0.
This value will be used in Schedule, and will affect all functions that are using frame delta time, such as Actions. This value will take effect only one time.
|
inline |
Gets an projection.
|
inline |
Whether or not the replaced scene will receive the cleanup message.
If the new scene is pushed, then the old scene won't receive the "cleanup" message. If the new scene replaces the old one, the it will receive the "cleanup" message.
|
inline |
This object will be visited after the main scene is visited.
This object MUST implement the "visit" function. Useful to hook a notification object, like Notifications (http://github.com/manucorporat/CCNotifications)
| void setNotificationNode | ( | Node * | node | ) |
Sets the notification node.
| Vec2 getVisibleSize | ( | ) | const |
Returns visible size of the render view in points.
The value is equal to Director::getCanvasSize() if don't invoke RenderView::setDesignResolutionSize().
Converts a point from screen coordinates to the rendering coordinate system.
Useful for mapping (multi)touch input to the current scene layout, taking into account orientation (portrait or landscape) and viewport settings.
Converts an rendering coordinate to a screen coordinate.
Useful to convert node points to window points for calls such as glScissor.
| float getZEye | ( | ) | const |
Gets the distance between camera and near clipping frame.
It is correct for default camera that near clipping frame is same as the screen.
| void runWithScene | ( | Scene * | scene | ) |
| void pushScene | ( | Scene * | scene | ) |
Suspends the execution of the running scene, pushing it on the stack of suspended scenes.
The new scene will be executed. Try to avoid big stacks of pushed scenes to reduce memory allocation. ONLY call it if there is a running scene.
| void popScene | ( | ) |
Pops out a scene from the stack.
This scene will replace the running one. The running scene will be deleted. If there are no more scenes in the stack the execution is terminated. ONLY call it if there is a running scene.
| void popToRootScene | ( | ) |
Pops out all scenes from the stack until the root scene in the queue.
This scene will replace the running one. Internally it will call popToSceneStackLevel(1).
| void popToSceneStackLevel | ( | int | level | ) |
Pops out all scenes from the stack until it reaches level.
If level is 0, it will end the director. If level is 1, it will pop all scenes until it reaches to root scene. If level is <= than the current stack level, it won't do anything.
| void replaceScene | ( | Scene * | scene | ) |
Replaces the running scene with a new one.
The running scene is terminated. ONLY call it if there is a running scene.
| Scene * popPreviousSceneOut | ( | ) |
Removes the previous scene from the stack if it exists, and returns it If there are less than 2 scenes in the stack, or if there is a scene switch about to occur, then this call would be invalid, and a nullptr will be returned.
Returns previous scene or nullptr if invalid
| void end | ( | ) |
Ends the execution, releases the running scene.
@lua endToLua
| void pause | ( | ) |
Pauses the running scene.
The running scene will be drawed but all scheduled timers will be paused. While paused, the draw rate will be 4 FPS to reduce CPU consumption.
| void resume | ( | ) |
Resumes the paused scene.
The scheduled timers will be activated again. The "delta time" will be 0 (as if the game wasn't paused).
| void stopAnimation | ( | ) |
Stops the animation.
Nothing will be drawn. The main loop won't be triggered anymore. If you don't want to pause your animation call [pause] instead.
| void startAnimation | ( | ) |
The main loop is triggered again.
Call this function only if [stopAnimation] was called earlier.
| void drawScene | ( | ) |
Draw the scene.
This method is called every frame. Don't call it manually.
| void purgeCachedData | ( | ) |
Removes all axmol cached data.
It will purge the TextureCache, SpriteFrameCache, LabelBMFont cache
| void setRenderDefaults | ( | ) |
Sets the Render default values.
It will enable alpha blending, disable depth test.
| void renderFrame | ( | float | dt | ) |
Invoke render frame with delta time.
Then calculateDeltaTime can just use the delta time directly. The delta time paseed may include vsync time. See issue #17806
| void setContentScaleFactor | ( | float | scaleFactor | ) |
The size in pixels of the surface.
It could be different than the screen size. High-res devices might have a higher surface size than the screen size. Only available when compiled using SDK >= 4.0.
|
inline |
Gets content scale factor.
|
inline |
Gets the JobSystem associated with this director.
|
inline |
Gets the Scheduler associated with this director.
| void setScheduler | ( | Scheduler * | scheduler | ) |
Sets the Scheduler associated with this director.
|
inline |
Gets the ActionManager associated with this director.
| void setActionManager | ( | ActionManager * | actionManager | ) |
Sets the ActionManager associated with this director.
|
inline |
Gets the EventDispatcher associated with this director.
| void setEventDispatcher | ( | EventDispatcher * | dispatcher | ) |
Sets the EventDispatcher associated with this director.
|
inline |
Returns the Renderer associated with this director.
| void loadMatrix | ( | MATRIX_STACK_TYPE | type, |
| const Mat4 & | mat ) |
Adds a matrix to the top of specified type of matrix stack.
| type | Matrix type. |
| mat | The matrix that to be added. |
| void multiplyMatrix | ( | MATRIX_STACK_TYPE | type, |
| const Mat4 & | mat ) |
Multiplies a matrix to the top of specified type of matrix stack.
| type | Matrix type. |
| mat | The matrix that to be multiplied. |
|
inline |
returns the axmol thread id.
Useful to know if certain code is already running on the axmol thread