2010-08-02 10:58:00 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
|
|
|
Copyright (c) 2010-2013 cocos2d-x.org
|
|
|
|
Copyright (c) 2011 Zynga Inc.
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2010-08-02 10:58:00 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CCDIRECTOR_H__
|
|
|
|
#define __CCDIRECTOR_H__
|
|
|
|
|
2014-09-10 07:50:02 +08:00
|
|
|
#include <stack>
|
2015-08-13 15:14:10 +08:00
|
|
|
#include <thread>
|
2016-07-20 12:43:40 +08:00
|
|
|
#include <chrono>
|
2013-07-19 13:42:45 +08:00
|
|
|
|
2014-09-10 08:17:07 +08:00
|
|
|
#include "platform/CCPlatformMacros.h"
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "base/CCRef.h"
|
2014-04-27 01:35:57 +08:00
|
|
|
#include "base/CCVector.h"
|
2014-08-29 16:44:20 +08:00
|
|
|
#include "2d/CCScene.h"
|
2014-04-26 13:03:25 +08:00
|
|
|
#include "math/CCMath.h"
|
2014-09-10 07:50:02 +08:00
|
|
|
#include "platform/CCGL.h"
|
2014-08-02 16:31:16 +08:00
|
|
|
#include "platform/CCGLView.h"
|
2011-06-20 17:31:38 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_BEGIN
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
2015-03-24 11:15:40 +08:00
|
|
|
* @addtogroup base
|
2012-06-20 18:09:11 +08:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-05-22 08:20:47 +08:00
|
|
|
/* Forward declarations. */
|
2013-06-20 14:13:12 +08:00
|
|
|
class LabelAtlas;
|
2014-08-02 16:31:16 +08:00
|
|
|
//class GLView;
|
2013-06-20 14:13:12 +08:00
|
|
|
class DirectorDelegate;
|
|
|
|
class Node;
|
|
|
|
class Scheduler;
|
|
|
|
class ActionManager;
|
2013-10-26 15:04:01 +08:00
|
|
|
class EventDispatcher;
|
2013-12-21 16:56:28 +08:00
|
|
|
class EventCustom;
|
|
|
|
class EventListenerCustom;
|
2013-11-07 18:52:36 +08:00
|
|
|
class TextureCache;
|
2013-12-18 09:50:17 +08:00
|
|
|
class Renderer;
|
2014-08-07 15:23:31 +08:00
|
|
|
class Camera;
|
2014-03-22 20:55:08 +08:00
|
|
|
|
2014-01-11 09:11:14 +08:00
|
|
|
class Console;
|
2015-06-09 10:59:43 +08:00
|
|
|
namespace experimental
|
|
|
|
{
|
|
|
|
class FrameBuffer;
|
|
|
|
}
|
2015-06-04 15:53:13 +08:00
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/**
|
2015-03-18 21:39:50 +08:00
|
|
|
* @brief Matrix stack type.
|
|
|
|
*/
|
2014-04-02 16:47:23 +08:00
|
|
|
enum class MATRIX_STACK_TYPE
|
|
|
|
{
|
2015-03-18 21:39:50 +08:00
|
|
|
/// Model view matrix stack
|
2014-04-02 16:47:23 +08:00
|
|
|
MATRIX_STACK_MODELVIEW,
|
2015-03-18 21:39:50 +08:00
|
|
|
|
|
|
|
/// projection matrix stack
|
2014-04-02 16:47:23 +08:00
|
|
|
MATRIX_STACK_PROJECTION,
|
2015-03-18 21:39:50 +08:00
|
|
|
|
|
|
|
/// texture matrix stack
|
2014-04-02 16:47:23 +08:00
|
|
|
MATRIX_STACK_TEXTURE
|
|
|
|
};
|
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
@brief Class that creates and handles 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 buffer depth (default one is 0-bit)
|
|
|
|
- setting the projection (default one is 3D)
|
|
|
|
|
|
|
|
Since the Director is a singleton, the standard way to use it is by calling:
|
|
|
|
_ Director::getInstance()->methodName();
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
class CC_DLL Director : public Ref
|
2010-07-12 17:03:27 +08:00
|
|
|
{
|
2012-03-21 17:35:20 +08:00
|
|
|
public:
|
2017-06-05 13:37:50 +08:00
|
|
|
/** Director will trigger an event before set next scene. */
|
|
|
|
static const char* EVENT_BEFORE_SET_NEXT_SCENE;
|
|
|
|
/** Director will trigger an event after set next scene. */
|
|
|
|
static const char* EVENT_AFTER_SET_NEXT_SCENE;
|
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Director will trigger an event when projection type is changed. */
|
2015-10-27 17:32:57 +08:00
|
|
|
static const char* EVENT_PROJECTION_CHANGED;
|
|
|
|
/** Director will trigger an event before Schedule::update() is invoked. */
|
|
|
|
static const char* EVENT_BEFORE_UPDATE;
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Director will trigger an event after Schedule::update() is invoked. */
|
2013-12-21 16:56:28 +08:00
|
|
|
static const char* EVENT_AFTER_UPDATE;
|
2016-02-29 18:55:51 +08:00
|
|
|
/** Director will trigger an event while resetting Director */
|
|
|
|
static const char* EVENT_RESET;
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Director will trigger an event after Scene::render() is invoked. */
|
2013-12-21 16:56:28 +08:00
|
|
|
static const char* EVENT_AFTER_VISIT;
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Director will trigger an event after a scene is drawn, the data is sent to GPU. */
|
2013-12-21 16:56:28 +08:00
|
|
|
static const char* EVENT_AFTER_DRAW;
|
2017-05-26 11:09:24 +08:00
|
|
|
/** Director will trigger an event before a scene is drawn, right after clear. */
|
|
|
|
static const char* EVENT_BEFORE_DRAW;
|
2013-12-21 16:56:28 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* @brief Possible OpenGL projections used by director
|
2013-07-25 14:39:32 +08:00
|
|
|
*/
|
2013-07-26 04:36:19 +08:00
|
|
|
enum class Projection
|
2013-07-25 14:39:32 +08:00
|
|
|
{
|
2015-03-18 21:39:50 +08:00
|
|
|
/// Sets a 2D projection (orthogonal projection).
|
2013-07-26 04:36:19 +08:00
|
|
|
_2D,
|
2013-07-25 14:39:32 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/// Sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500.
|
2013-07-26 04:36:19 +08:00
|
|
|
_3D,
|
2013-07-25 14:39:32 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/// It calls "updateProjection" on the projection delegate.
|
2013-07-26 04:36:19 +08:00
|
|
|
CUSTOM,
|
2013-07-25 14:39:32 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/// Default projection is 3D projection.
|
2013-07-26 04:36:19 +08:00
|
|
|
DEFAULT = _3D,
|
2013-07-25 14:39:32 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
2015-03-19 10:33:11 +08:00
|
|
|
* Returns a shared instance of the director.
|
|
|
|
* @js _getInstance
|
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
static Director* getInstance();
|
|
|
|
|
2015-03-19 10:33:11 +08:00
|
|
|
/**
|
|
|
|
* @deprecated Use getInstance() instead.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static Director* sharedDirector() { return Director::getInstance(); }
|
2015-03-18 21:39:50 +08:00
|
|
|
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
2015-03-18 21:39:50 +08:00
|
|
|
Director();
|
|
|
|
|
2013-09-13 13:52:42 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2016-08-19 09:13:15 +08:00
|
|
|
~Director();
|
|
|
|
bool init();
|
2010-07-16 14:09:31 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// attribute
|
2010-07-16 14:09:31 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Gets current running Scene. Director can only run one Scene at a time. */
|
2016-09-12 09:44:21 +08:00
|
|
|
Scene* getRunningScene() { return _runningScene; }
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Gets the FPS value. */
|
2016-09-12 09:44:21 +08:00
|
|
|
float getAnimationInterval() { return _animationInterval; }
|
2015-09-06 17:59:36 +08:00
|
|
|
/** Sets the FPS value. FPS = 1/interval. */
|
2016-08-19 09:13:15 +08:00
|
|
|
void setAnimationInterval(float interval);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2015-09-06 17:59:36 +08:00
|
|
|
/** Whether or not displaying the FPS on the bottom-left corner of the screen. */
|
2016-09-12 09:44:21 +08:00
|
|
|
bool isDisplayStats() { return _displayStats; }
|
2015-09-06 17:59:36 +08:00
|
|
|
/** Display the FPS on the bottom-left corner of the screen. */
|
2016-09-12 09:44:21 +08:00
|
|
|
void setDisplayStats(bool displayStats) { _displayStats = displayStats; }
|
2012-04-13 11:22:17 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Get seconds per frame. */
|
2016-09-12 09:44:21 +08:00
|
|
|
float getSecondsPerFrame() { return _secondsPerFrame; }
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* Get the GLView.
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
GLView* getOpenGLView() { return _openGLView; }
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* Sets the GLView.
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2014-01-31 07:40:56 +08:00
|
|
|
void setOpenGLView(GLView *openGLView);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/*
|
2015-03-19 10:33:11 +08:00
|
|
|
* Gets singleton of TextureCache.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2013-11-07 18:52:36 +08:00
|
|
|
TextureCache* getTextureCache() const;
|
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Whether or not `_nextDeltaTimeZero` is set to 0. */
|
2016-09-12 09:44:21 +08:00
|
|
|
bool isNextDeltaTimeZero() { return _nextDeltaTimeZero; }
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
2015-09-22 16:08:23 +08:00
|
|
|
* 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.
|
2015-03-18 21:39:50 +08:00
|
|
|
* This value will take effect only one time.
|
|
|
|
*/
|
2013-07-26 04:36:19 +08:00
|
|
|
void setNextDeltaTimeZero(bool nextDeltaTimeZero);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Whether or not the Director is paused. */
|
2016-09-12 09:44:21 +08:00
|
|
|
bool isPaused() { return _paused; }
|
2012-06-11 10:59:57 +08:00
|
|
|
|
2011-07-08 14:48:25 +08:00
|
|
|
/** How many frames were called since the director started */
|
2016-09-12 09:44:21 +08:00
|
|
|
unsigned int getTotalFrames() { return _totalFrames; }
|
2011-07-08 14:48:25 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Gets an OpenGL projection.
|
2015-03-19 10:33:11 +08:00
|
|
|
* @since v0.8.2
|
2013-09-13 11:41:20 +08:00
|
|
|
* @lua NA
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
Projection getProjection() { return _projection; }
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Sets OpenGL projection. */
|
2013-07-26 04:36:19 +08:00
|
|
|
void setProjection(Projection projection);
|
2013-02-27 15:44:36 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Sets the glViewport.*/
|
2013-02-27 15:44:36 +08:00
|
|
|
void setViewport();
|
2011-07-08 14:48:25 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Whether or not the replaced scene will receive the cleanup message.
|
2015-03-18 21:39:50 +08:00
|
|
|
* 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.
|
|
|
|
* @since v0.99.0
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
bool isSendCleanupToScene() { return _sendCleanupToScene; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** This object will be visited after the main scene is visited.
|
2015-03-18 21:39:50 +08:00
|
|
|
* This object MUST implement the "visit" function.
|
|
|
|
* Useful to hook a notification object, like Notifications (http://github.com/manucorporat/CCNotifications)
|
|
|
|
* @since v0.99.5
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2014-01-11 09:11:14 +08:00
|
|
|
Node* getNotificationNode() const { return _notificationNode; }
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* Sets the notification node.
|
|
|
|
* @see Director::getNotificationNode()
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void setNotificationNode(Node *node);
|
2012-11-13 11:06:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// window size
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Returns the size of the OpenGL view in points. */
|
2013-08-08 16:31:44 +08:00
|
|
|
const Size& getWinSize() const;
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Returns the size of the OpenGL view in pixels. */
|
2013-08-08 16:31:44 +08:00
|
|
|
Size getWinSizeInPixels() const;
|
2012-08-09 10:23:39 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* Returns visible size of the OpenGL view in points.
|
|
|
|
* The value is equal to `Director::getWinSize()` if don't invoke `GLView::setDesignResolutionSize()`.
|
2012-08-09 10:23:39 +08:00
|
|
|
*/
|
2013-07-07 13:01:21 +08:00
|
|
|
Size getVisibleSize() const;
|
2012-08-09 10:23:39 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Returns visible origin coordinate of the OpenGL view in points. */
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 getVisibleOrigin() const;
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2017-11-23 09:34:23 +08:00
|
|
|
/**
|
|
|
|
* Returns safe area rectangle of the OpenGL view in points.
|
|
|
|
*/
|
|
|
|
Rect getSafeAreaRect() const;
|
|
|
|
|
|
|
|
/**
|
2015-03-18 21:39:50 +08:00
|
|
|
* Converts a screen coordinate to an OpenGL coordinate.
|
|
|
|
* Useful to convert (multi) touch coordinates to the current layout (portrait or landscape).
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 convertToGL(const Vec2& point);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* Converts an OpenGL coordinate to a screen coordinate.
|
|
|
|
* Useful to convert node points to window points for calls such as glScissor.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 convertToUI(const Vec2& point);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
2015-09-06 17:59:36 +08:00
|
|
|
* Gets the distance between camera and near clipping frame.
|
|
|
|
* It is correct for default camera that near clipping frame is same as the screen.
|
2015-03-18 21:39:50 +08:00
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
float getZEye() const;
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// Scene Management
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* Enters the Director's main loop with the given Scene.
|
2012-04-19 14:35:52 +08:00
|
|
|
* Call it to run only your FIRST scene.
|
|
|
|
* Don't call it if there is already a running scene.
|
2012-04-13 11:22:17 +08:00
|
|
|
*
|
|
|
|
* It will call pushScene: and then it will call startAnimation
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-07-26 04:36:19 +08:00
|
|
|
void runWithScene(Scene *scene);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* Suspends the execution of the running scene, pushing it on the stack of suspended scenes.
|
2012-04-19 14:35:52 +08:00
|
|
|
* 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.
|
|
|
|
*/
|
2013-07-26 04:36:19 +08:00
|
|
|
void pushScene(Scene *scene);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* Pops out a scene from the stack.
|
2012-04-19 14:35:52 +08:00
|
|
|
* 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.
|
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
void popScene();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* Pops out all scenes from the stack until the root scene in the queue.
|
2012-06-12 02:50:32 +08:00
|
|
|
* This scene will replace the running one.
|
2015-03-18 21:39:50 +08:00
|
|
|
* Internally it will call `popToSceneStackLevel(1)`.
|
2012-06-12 02:50:32 +08:00
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
void popToRootScene();
|
2012-06-11 10:59:57 +08:00
|
|
|
|
2013-09-23 02:39:42 +08:00
|
|
|
/** Pops out all scenes from the stack until it reaches `level`.
|
2013-05-01 06:33:22 +08:00
|
|
|
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 popToSceneStackLevel(int level);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Replaces the running scene with a new one. The running scene is terminated.
|
|
|
|
* ONLY call it if there is a running scene.
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-07-26 04:36:19 +08:00
|
|
|
void replaceScene(Scene *scene);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Ends the execution, releases the running scene.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @lua endToLua
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
void end();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Pauses the running scene.
|
2015-03-18 21:39:50 +08:00
|
|
|
* 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.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
void pause();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Resumes the paused scene.
|
|
|
|
* The scheduled timers will be activated again.
|
|
|
|
* The "delta time" will be 0 (as if the game wasn't paused).
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
void resume();
|
2014-12-28 11:55:06 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/*
|
2015-03-19 10:33:11 +08:00
|
|
|
* Restart the director.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2014-12-28 11:55:06 +08:00
|
|
|
void restart();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Stops the animation. Nothing will be drawn. The main loop won't be triggered anymore.
|
2015-03-18 21:39:50 +08:00
|
|
|
* If you don't want to pause your animation call [pause] instead.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2016-08-19 09:13:15 +08:00
|
|
|
void stopAnimation();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** The main loop is triggered again.
|
2015-03-18 21:39:50 +08:00
|
|
|
* Call this function only if [stopAnimation] was called earlier.
|
|
|
|
* @warning Don't call this function to start the main loop. To run the main loop call runWithScene.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2016-08-19 09:13:15 +08:00
|
|
|
void startAnimation();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Draw the scene.
|
2015-03-18 21:39:50 +08:00
|
|
|
* This method is called every frame. Don't call it manually.
|
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
void drawScene();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Memory Helper
|
|
|
|
|
2013-09-23 02:39:42 +08:00
|
|
|
/** Removes all cocos2d cached data.
|
2015-03-18 21:39:50 +08:00
|
|
|
* It will purge the TextureCache, SpriteFrameCache, LabelBMFont cache
|
|
|
|
* @since v0.99.3
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
void purgeCachedData();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Sets the default values based on the Configuration info. */
|
2013-08-08 16:31:44 +08:00
|
|
|
void setDefaultValues();
|
2013-06-07 03:23:44 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// OpenGL Helper
|
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Sets the OpenGL default values.
|
|
|
|
* It will enable alpha blending, disable depth test.
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
2015-03-18 21:39:50 +08:00
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
void setGLDefaultValues();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Enables/disables OpenGL alpha blending. */
|
2013-08-08 16:31:44 +08:00
|
|
|
void setAlphaBlending(bool on);
|
2014-12-24 11:53:38 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Sets clear values for the color buffers,
|
2015-03-19 10:33:11 +08:00
|
|
|
* value range of each element is [0.0, 1.0].
|
|
|
|
* @js NA
|
|
|
|
*/
|
2014-12-24 11:53:38 +08:00
|
|
|
void setClearColor(const Color4F& clearColor);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Enables/disables OpenGL depth test. */
|
2013-08-08 16:31:44 +08:00
|
|
|
void setDepthTest(bool on);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2016-08-19 09:13:15 +08:00
|
|
|
void mainLoop();
|
2017-05-23 08:46:13 +08:00
|
|
|
/** Invoke main loop with delta time. Then `calculateDeltaTime` can just use the delta time directly.
|
|
|
|
* The delta time paseed may include vsync time. See issue #17806
|
|
|
|
* @since 3.16
|
|
|
|
*/
|
|
|
|
void mainLoop(float dt);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** The size in pixels of the surface. It could be different than the screen size.
|
2015-03-18 21:39:50 +08:00
|
|
|
* High-res devices might have a higher surface size than the screen size.
|
|
|
|
* Only available when compiled using SDK >= 4.0.
|
|
|
|
* @since v0.99.4
|
2015-03-19 10:33:11 +08:00
|
|
|
*/
|
2012-08-01 15:30:12 +08:00
|
|
|
void setContentScaleFactor(float scaleFactor);
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* Gets content scale factor.
|
|
|
|
* @see Director::setContentScaleFactor()
|
|
|
|
*/
|
2014-01-11 09:11:14 +08:00
|
|
|
float getContentScaleFactor() const { return _contentScaleFactor; }
|
2010-12-29 18:01:37 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Gets the Scheduler associated with this director.
|
|
|
|
* @since v2.0
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2014-01-11 09:11:14 +08:00
|
|
|
Scheduler* getScheduler() const { return _scheduler; }
|
2013-07-23 15:19:26 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Sets the Scheduler associated with this director.
|
|
|
|
* @since v2.0
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-07-23 15:19:26 +08:00
|
|
|
void setScheduler(Scheduler* scheduler);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Gets the ActionManager associated with this director.
|
|
|
|
* @since v2.0
|
2013-07-23 15:19:26 +08:00
|
|
|
*/
|
2014-01-11 09:11:14 +08:00
|
|
|
ActionManager* getActionManager() const { return _actionManager; }
|
2013-07-23 15:19:26 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Sets the ActionManager associated with this director.
|
|
|
|
* @since v2.0
|
2013-07-23 15:19:26 +08:00
|
|
|
*/
|
|
|
|
void setActionManager(ActionManager* actionManager);
|
2013-10-26 15:04:01 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Gets the EventDispatcher associated with this director.
|
|
|
|
* @since v3.0
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
2013-10-26 15:04:01 +08:00
|
|
|
*/
|
2014-01-11 09:11:14 +08:00
|
|
|
EventDispatcher* getEventDispatcher() const { return _eventDispatcher; }
|
2013-10-26 15:04:01 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Sets the EventDispatcher associated with this director.
|
|
|
|
* @since v3.0
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
2013-10-26 15:04:01 +08:00
|
|
|
*/
|
|
|
|
void setEventDispatcher(EventDispatcher* dispatcher);
|
2013-12-18 09:50:17 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Returns the Renderer associated with this director.
|
|
|
|
* @since v3.0
|
2013-12-18 09:50:17 +08:00
|
|
|
*/
|
2014-01-11 09:11:14 +08:00
|
|
|
Renderer* getRenderer() const { return _renderer; }
|
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Returns the Console associated with this director.
|
|
|
|
* @since v3.0
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
2014-01-11 09:11:14 +08:00
|
|
|
*/
|
|
|
|
Console* getConsole() const { return _console; }
|
2013-12-18 09:50:17 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/* Gets delta time since last tick to main loop. */
|
2013-07-23 15:19:26 +08:00
|
|
|
float getDeltaTime() const;
|
2013-09-30 16:22:55 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-18 21:39:50 +08:00
|
|
|
* Gets Frame Rate.
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
2013-09-30 16:22:55 +08:00
|
|
|
*/
|
|
|
|
float getFrameRate() const { return _frameRate; }
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
2015-03-19 10:33:11 +08:00
|
|
|
* Clones a specified type matrix and put it to the top of specified type of matrix stack.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2014-11-05 08:46:14 +08:00
|
|
|
void pushMatrix(MATRIX_STACK_TYPE type);
|
2016-10-28 09:33:31 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clones a projection matrix and put it to the top of projection matrix stack.
|
|
|
|
* @param index The index of projection matrix stack.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2017-02-07 09:41:19 +08:00
|
|
|
void pushProjectionMatrix(size_t index);
|
2016-10-28 09:33:31 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/** Pops the top matrix of the specified type of matrix stack.
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
|
|
|
*/
|
2014-11-05 08:46:14 +08:00
|
|
|
void popMatrix(MATRIX_STACK_TYPE type);
|
2016-10-28 09:33:31 +08:00
|
|
|
|
|
|
|
/** Pops the top matrix of the projection matrix stack.
|
|
|
|
* @param index The index of projection matrix stack.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2017-02-07 09:41:19 +08:00
|
|
|
void popProjectionMatrix(size_t index);
|
2016-10-28 09:33:31 +08:00
|
|
|
|
2015-09-22 16:08:23 +08:00
|
|
|
/** Adds an identity matrix to the top of specified type of matrix stack.
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
|
|
|
*/
|
2014-11-05 08:46:14 +08:00
|
|
|
void loadIdentityMatrix(MATRIX_STACK_TYPE type);
|
2016-10-28 09:33:31 +08:00
|
|
|
|
|
|
|
/** Adds an identity matrix to the top of projection matrix stack.
|
|
|
|
* @param index The index of projection matrix stack.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2017-02-07 09:41:19 +08:00
|
|
|
void loadProjectionIdentityMatrix(size_t index);
|
2016-10-28 09:33:31 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
|
|
|
* Adds a matrix to the top of specified type of matrix stack.
|
|
|
|
*
|
|
|
|
* @param type Matrix type.
|
|
|
|
* @param mat The matrix that to be added.
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
2015-03-18 21:39:50 +08:00
|
|
|
*/
|
2014-11-05 08:46:14 +08:00
|
|
|
void loadMatrix(MATRIX_STACK_TYPE type, const Mat4& mat);
|
2016-10-28 09:33:31 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a matrix to the top of projection matrix stack.
|
|
|
|
*
|
|
|
|
* @param mat The matrix that to be added.
|
|
|
|
* @param index The index of projection matrix stack.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2017-02-07 09:41:19 +08:00
|
|
|
void loadProjectionMatrix(const Mat4& mat, size_t index);
|
2016-10-28 09:33:31 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
2015-09-22 16:08:23 +08:00
|
|
|
* Multiplies a matrix to the top of specified type of matrix stack.
|
2015-03-18 21:39:50 +08:00
|
|
|
*
|
|
|
|
* @param type Matrix type.
|
2015-09-22 16:08:23 +08:00
|
|
|
* @param mat The matrix that to be multiplied.
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
2015-03-18 21:39:50 +08:00
|
|
|
*/
|
2014-11-05 08:46:14 +08:00
|
|
|
void multiplyMatrix(MATRIX_STACK_TYPE type, const Mat4& mat);
|
2016-10-28 09:33:31 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Multiplies a matrix to the top of projection matrix stack.
|
|
|
|
*
|
|
|
|
* @param mat The matrix that to be multiplied.
|
|
|
|
* @param index The index of projection matrix stack.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2017-02-07 09:41:19 +08:00
|
|
|
void multiplyProjectionMatrix(const Mat4& mat, size_t index);
|
2016-10-28 09:33:31 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
2015-03-19 10:33:11 +08:00
|
|
|
* Gets the top matrix of specified type of matrix stack.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2016-02-09 03:25:37 +08:00
|
|
|
const Mat4& getMatrix(MATRIX_STACK_TYPE type) const;
|
2016-10-28 09:33:31 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the top matrix of projection matrix stack.
|
|
|
|
* @param index The index of projection matrix stack.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2017-02-07 09:41:19 +08:00
|
|
|
const Mat4& getProjectionMatrix(size_t index) const;
|
2016-10-28 09:33:31 +08:00
|
|
|
|
2015-03-18 21:39:50 +08:00
|
|
|
/**
|
2015-09-22 16:08:23 +08:00
|
|
|
* Clear all types of matrix stack, and add identity matrix to these matrix stacks.
|
2015-03-19 10:33:11 +08:00
|
|
|
* @js NA
|
|
|
|
*/
|
2014-11-05 08:46:14 +08:00
|
|
|
void resetMatrixStack();
|
|
|
|
|
2016-10-28 09:33:31 +08:00
|
|
|
/**
|
|
|
|
* Init the projection matrix stack.
|
|
|
|
* @param stackCount The size of projection matrix stack.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2017-02-07 09:41:19 +08:00
|
|
|
void initProjectionMatrixStack(size_t stackCount);
|
2016-10-28 09:33:31 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the size of projection matrix stack.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2017-02-07 09:41:19 +08:00
|
|
|
size_t getProjectionMatrixStackSize();
|
2016-10-28 09:33:31 +08:00
|
|
|
|
2015-08-13 15:14:10 +08:00
|
|
|
/**
|
|
|
|
* returns the cocos2d thread id.
|
|
|
|
Useful to know if certain code is already running on the cocos2d thread
|
|
|
|
*/
|
|
|
|
const std::thread::id& getCocos2dThreadId() const { return _cocos2d_thread_id; }
|
|
|
|
|
2016-08-19 09:13:15 +08:00
|
|
|
/**
|
|
|
|
* returns whether or not the Director is in a valid state
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
bool isValid() const { return !_invalid; }
|
2016-08-19 09:13:15 +08:00
|
|
|
|
2010-07-12 17:03:27 +08:00
|
|
|
protected:
|
2014-12-30 10:09:56 +08:00
|
|
|
void reset();
|
|
|
|
|
2017-06-05 13:37:50 +08:00
|
|
|
|
|
|
|
virtual void startAnimation(SetIntervalReason reason);
|
|
|
|
virtual void setAnimationInterval(float interval, SetIntervalReason reason);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void purgeDirector();
|
2018-10-24 16:00:33 +08:00
|
|
|
bool _purgeDirectorInNextLoop = false; // this flag will be set to true in end()
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-12-28 11:55:06 +08:00
|
|
|
void restartDirector();
|
2018-10-24 16:00:33 +08:00
|
|
|
bool _restartDirectorInNextLoop = false; // this flag will be set to true in restart()
|
2014-12-28 11:55:06 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void setNextScene();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2017-06-05 13:37:50 +08:00
|
|
|
void updateFrameRate();
|
2017-06-20 09:02:13 +08:00
|
|
|
#if !CC_STRIP_FPS
|
2012-04-13 11:22:17 +08:00
|
|
|
void showStats();
|
|
|
|
void createStatsLabel();
|
|
|
|
void calculateMPF();
|
2013-12-05 17:19:01 +08:00
|
|
|
void getFPSImageData(unsigned char** datapointer, ssize_t* length);
|
2017-06-20 09:02:13 +08:00
|
|
|
#endif
|
2013-02-27 09:38:30 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** calculates delta time since last time it was called */
|
2012-04-13 11:22:17 +08:00
|
|
|
void calculateDeltaTime();
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2013-11-07 18:52:36 +08:00
|
|
|
//textureCache creation or release
|
|
|
|
void initTextureCache();
|
|
|
|
void destroyTextureCache();
|
|
|
|
|
2014-11-05 08:46:14 +08:00
|
|
|
void initMatrixStack();
|
|
|
|
|
|
|
|
std::stack<Mat4> _modelViewMatrixStack;
|
2016-10-28 09:33:31 +08:00
|
|
|
/** In order to support GL MultiView features, we need to use the matrix array,
|
|
|
|
but we don't know the number of MultiView, so using the vector instead.
|
|
|
|
*/
|
|
|
|
std::vector< std::stack<Mat4> > _projectionMatrixStackList;
|
2014-11-05 08:46:14 +08:00
|
|
|
std::stack<Mat4> _textureMatrixStack;
|
|
|
|
|
2013-07-23 15:19:26 +08:00
|
|
|
/** Scheduler associated with this director
|
|
|
|
@since v2.0
|
|
|
|
*/
|
2018-10-24 16:00:33 +08:00
|
|
|
Scheduler *_scheduler = nullptr;
|
2013-07-23 15:19:26 +08:00
|
|
|
|
|
|
|
/** ActionManager associated with this director
|
|
|
|
@since v2.0
|
|
|
|
*/
|
2018-10-24 16:00:33 +08:00
|
|
|
ActionManager *_actionManager = nullptr;
|
2013-10-26 15:04:01 +08:00
|
|
|
|
|
|
|
/** EventDispatcher associated with this director
|
|
|
|
@since v3.0
|
|
|
|
*/
|
2018-10-24 16:00:33 +08:00
|
|
|
EventDispatcher* _eventDispatcher = nullptr;
|
|
|
|
EventCustom* _eventProjectionChanged = nullptr;
|
|
|
|
EventCustom* _eventBeforeDraw =nullptr;
|
|
|
|
EventCustom* _eventAfterDraw = nullptr;
|
|
|
|
EventCustom* _eventAfterVisit = nullptr;
|
|
|
|
EventCustom* _eventBeforeUpdate = nullptr;
|
|
|
|
EventCustom* _eventAfterUpdate = nullptr;
|
|
|
|
EventCustom* _eventResetDirector = nullptr;
|
|
|
|
EventCustom* _beforeSetNextScene = nullptr;
|
|
|
|
EventCustom* _afterSetNextScene = nullptr;
|
2013-09-03 18:22:03 +08:00
|
|
|
|
2013-07-23 15:19:26 +08:00
|
|
|
/* delta time since last tick to main loop */
|
2018-10-24 16:00:33 +08:00
|
|
|
float _deltaTime = 0.0f;
|
|
|
|
bool _deltaTimePassedByCaller = false;
|
2013-07-23 15:19:26 +08:00
|
|
|
|
2014-07-31 00:53:04 +08:00
|
|
|
/* The _openGLView, where everything is rendered, GLView is a abstract class,cocos2d-x provide GLViewImpl
|
|
|
|
which inherit from it as default renderer context,you can have your own by inherit from it*/
|
2018-10-24 16:00:33 +08:00
|
|
|
GLView *_openGLView = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-07 18:52:36 +08:00
|
|
|
//texture cache belongs to this director
|
2018-10-24 16:00:33 +08:00
|
|
|
TextureCache *_textureCache = nullptr;
|
2013-11-07 18:52:36 +08:00
|
|
|
|
2018-10-24 16:00:33 +08:00
|
|
|
float _animationInterval = 0.0f;
|
|
|
|
float _oldAnimationInterval = 0.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2018-10-24 16:00:33 +08:00
|
|
|
bool _displayStats = false;
|
|
|
|
float _accumDt = 0.0f;
|
|
|
|
float _frameRate = 0.0f;
|
2012-04-13 11:22:17 +08:00
|
|
|
|
2018-10-24 16:00:33 +08:00
|
|
|
LabelAtlas *_FPSLabel = nullptr;
|
|
|
|
LabelAtlas *_drawnBatchesLabel = nullptr;
|
|
|
|
LabelAtlas *_drawnVerticesLabel = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-11 10:59:57 +08:00
|
|
|
/** Whether or not the Director is paused */
|
2018-10-24 16:00:33 +08:00
|
|
|
bool _paused = false;
|
2012-06-11 10:59:57 +08:00
|
|
|
|
2011-07-08 14:48:25 +08:00
|
|
|
/* How many frames were called since the director started */
|
2018-10-24 16:00:33 +08:00
|
|
|
unsigned int _totalFrames = 0;
|
|
|
|
unsigned int _frames = 0;
|
|
|
|
float _secondsPerFrame = 1.f;
|
2013-11-27 10:35:12 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/* The running scene */
|
2018-10-24 16:00:33 +08:00
|
|
|
Scene *_runningScene = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/* will be the next 'runningScene' in the next frame
|
|
|
|
nextScene is a weak reference. */
|
2018-10-24 16:00:33 +08:00
|
|
|
Scene *_nextScene = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-01 16:39:42 +08:00
|
|
|
/* If true, then "old" scene will receive the cleanup message */
|
2018-10-24 16:00:33 +08:00
|
|
|
bool _sendCleanupToScene = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/* scheduled scenes */
|
2013-12-07 10:48:02 +08:00
|
|
|
Vector<Scene*> _scenesStack;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/* last time the main loop was updated */
|
2016-07-20 12:43:40 +08:00
|
|
|
std::chrono::steady_clock::time_point _lastUpdate;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/* whether or not the next delta time will be zero */
|
2018-10-24 16:00:33 +08:00
|
|
|
bool _nextDeltaTimeZero = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/* projection used */
|
2018-10-24 16:00:33 +08:00
|
|
|
Projection _projection = Projection::DEFAULT;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/* window size in points */
|
2018-10-24 16:00:33 +08:00
|
|
|
Size _winSizeInPoints = Size::ZERO;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/* content scale factor */
|
2018-10-24 16:00:33 +08:00
|
|
|
float _contentScaleFactor = 1.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/* This object will be visited after the scene. Useful to hook a notification node */
|
2018-10-24 16:00:33 +08:00
|
|
|
Node *_notificationNode = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-01-11 09:11:14 +08:00
|
|
|
/* Renderer for the Director */
|
2018-10-24 16:00:33 +08:00
|
|
|
Renderer *_renderer = nullptr;
|
2014-01-11 09:11:14 +08:00
|
|
|
|
|
|
|
/* Console for the director */
|
2018-10-24 16:00:33 +08:00
|
|
|
Console *_console = nullptr;
|
2014-03-22 20:55:08 +08:00
|
|
|
|
2018-10-24 16:00:33 +08:00
|
|
|
bool _isStatusLabelUpdated = true;
|
2015-04-02 23:35:56 +08:00
|
|
|
|
2015-08-13 15:14:10 +08:00
|
|
|
/* cocos2d thread id */
|
|
|
|
std::thread::id _cocos2d_thread_id;
|
|
|
|
|
2016-08-19 09:13:15 +08:00
|
|
|
/* whether or not the director is in a valid state */
|
2018-10-24 16:00:33 +08:00
|
|
|
bool _invalid = false;
|
2016-08-19 09:13:15 +08:00
|
|
|
|
2014-07-31 00:53:04 +08:00
|
|
|
// GLView will recreate stats labels to fit visible rect
|
2014-08-02 16:31:16 +08:00
|
|
|
friend class GLView;
|
2010-08-02 10:58:00 +08:00
|
|
|
};
|
|
|
|
|
2016-08-19 09:13:15 +08:00
|
|
|
// FIXME: Added for backward compatibility in case
|
|
|
|
// someone is subclassing it.
|
|
|
|
// Should be removed in v4.0
|
2013-06-20 14:13:12 +08:00
|
|
|
class DisplayLinkDirector : public Director
|
2016-08-19 09:13:15 +08:00
|
|
|
{};
|
2010-08-02 10:58:00 +08:00
|
|
|
|
2016-08-19 09:13:15 +08:00
|
|
|
// end of base group
|
|
|
|
/** @} */
|
2010-08-02 10:58:00 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_END
|
2010-08-02 10:58:00 +08:00
|
|
|
|
|
|
|
#endif // __CCDIRECTOR_H__
|