2010-08-02 10:58:00 +08:00
|
|
|
/****************************************************************************
|
2012-09-24 21:22:20 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2011-03-19 10:59:01 +08:00
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
2011-07-05 14:51:17 +08:00
|
|
|
Copyright (c) 2011 Zynga Inc.
|
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__
|
|
|
|
|
2012-06-19 13:50:11 +08:00
|
|
|
#include "platform/CCPlatformMacros.h"
|
|
|
|
#include "cocoa/CCObject.h"
|
2011-01-15 18:05:35 +08:00
|
|
|
#include "ccTypes.h"
|
2012-06-19 13:50:11 +08:00
|
|
|
#include "cocoa/CCGeometry.h"
|
|
|
|
#include "cocoa/CCArray.h"
|
2012-04-13 11:22:17 +08:00
|
|
|
#include "CCGL.h"
|
2012-03-14 14:55:17 +08:00
|
|
|
#include "kazmath/mat4.h"
|
2013-05-23 15:06:57 +08:00
|
|
|
#include "label_nodes/CCLabelAtlas.h"
|
2012-08-28 12:04:51 +08:00
|
|
|
#include "ccTypeInfo.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
|
|
|
/**
|
|
|
|
* @addtogroup base_nodes
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2010-07-12 17:03:27 +08:00
|
|
|
/** @typedef ccDirectorProjection
|
|
|
|
Possible OpenGL projections used by director
|
|
|
|
*/
|
|
|
|
typedef enum {
|
2012-04-19 14:35:52 +08:00
|
|
|
/// sets a 2D projection (orthogonal projection)
|
|
|
|
kCCDirectorProjection2D,
|
|
|
|
|
|
|
|
/// sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500.
|
|
|
|
kCCDirectorProjection3D,
|
|
|
|
|
|
|
|
/// it calls "updateProjection" on the projection delegate.
|
|
|
|
kCCDirectorProjectionCustom,
|
|
|
|
|
2012-09-16 05:19:14 +08:00
|
|
|
/// Default projection is 3D projection
|
2012-04-19 14:35:52 +08:00
|
|
|
kCCDirectorProjectionDefault = kCCDirectorProjection3D,
|
2010-07-12 17:03:27 +08:00
|
|
|
} ccDirectorProjection;
|
|
|
|
|
2012-05-22 08:20:47 +08:00
|
|
|
/* Forward declarations. */
|
2012-06-11 10:59:57 +08:00
|
|
|
class CCLabelAtlas;
|
2010-07-12 17:03:27 +08:00
|
|
|
class CCScene;
|
2011-03-07 17:11:57 +08:00
|
|
|
class CCEGLView;
|
2012-03-14 14:55:17 +08:00
|
|
|
class CCDirectorDelegate;
|
2011-11-25 10:13:59 +08:00
|
|
|
class CCNode;
|
2012-04-13 11:22:17 +08:00
|
|
|
class CCScheduler;
|
2012-03-14 14:55:17 +08:00
|
|
|
class CCActionManager;
|
2012-03-21 17:35:20 +08:00
|
|
|
class CCTouchDispatcher;
|
2013-06-02 10:11:43 +08:00
|
|
|
#ifdef KEYBOARD_SUPPORT
|
2013-05-31 20:29:32 +08:00
|
|
|
class CCKeyboardDispatcher;
|
2013-06-02 10:11:43 +08:00
|
|
|
#endif
|
2012-03-21 17:35:20 +08:00
|
|
|
class CCKeypadDispatcher;
|
|
|
|
class CCAccelerometer;
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/**
|
|
|
|
@brief Class that creates and handle the main Window and manages how
|
2010-07-12 17:03:27 +08:00
|
|
|
and when to execute the Scenes.
|
|
|
|
|
2010-09-28 16:18:05 +08:00
|
|
|
The CCDirector is also responsible for:
|
2010-12-29 18:01:37 +08:00
|
|
|
- initializing the OpenGL context
|
|
|
|
- setting the OpenGL pixel format (default on is RGB565)
|
|
|
|
- setting the OpenGL buffer depth (default one is 0-bit)
|
|
|
|
- setting the projection (default one is 3D)
|
2012-09-15 06:26:38 +08:00
|
|
|
- setting the orientation (default one is Portrait)
|
2010-07-12 17:03:27 +08:00
|
|
|
|
|
|
|
Since the CCDirector is a singleton, the standard way to use it is by calling:
|
2010-12-29 18:01:37 +08:00
|
|
|
_ CCDirector::sharedDirector()->methodName();
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2010-12-29 18:01:37 +08:00
|
|
|
The CCDirector also sets the default OpenGL context:
|
2010-07-12 17:03:27 +08:00
|
|
|
- GL_TEXTURE_2D is enabled
|
|
|
|
- GL_VERTEX_ARRAY is enabled
|
|
|
|
- GL_COLOR_ARRAY is enabled
|
|
|
|
- GL_TEXTURE_COORD_ARRAY is enabled
|
|
|
|
*/
|
2012-07-28 02:01:02 +08:00
|
|
|
class CC_DLL CCDirector : public CCObject, public TypeInfo
|
2010-07-12 17:03:27 +08:00
|
|
|
{
|
2012-03-21 17:35:20 +08:00
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
CCDirector(void);
|
|
|
|
virtual ~CCDirector(void);
|
|
|
|
virtual bool init(void);
|
2012-08-08 04:54:34 +08:00
|
|
|
virtual long getClassTypeInfo() {
|
2012-08-29 14:52:30 +08:00
|
|
|
static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CCDirector).name());
|
|
|
|
return id;
|
2012-07-28 02:01:02 +08:00
|
|
|
}
|
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
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Get current running Scene. Director can only run one Scene at the time */
|
|
|
|
inline CCScene* getRunningScene(void) { return m_pRunningScene; }
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Get the FPS value */
|
|
|
|
inline double getAnimationInterval(void) { return m_dAnimationInterval; }
|
|
|
|
/** Set the FPS value. */
|
|
|
|
virtual void setAnimationInterval(double dValue) = 0;
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Whether or not to display the FPS on the bottom-left corner */
|
|
|
|
inline bool isDisplayStats(void) { return m_bDisplayStats; }
|
|
|
|
/** Display the FPS on the bottom-left corner */
|
|
|
|
inline void setDisplayStats(bool bDisplayStats) { m_bDisplayStats = bDisplayStats; }
|
2012-04-13 11:22:17 +08:00
|
|
|
|
|
|
|
/** seconds per frame */
|
|
|
|
inline float getSecondsPerFrame() { return m_fSecondsPerFrame; }
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Get the CCEGLView, where everything is rendered */
|
2012-04-25 16:18:04 +08:00
|
|
|
inline CCEGLView* getOpenGLView(void) { return m_pobOpenGLView; }
|
|
|
|
void setOpenGLView(CCEGLView *pobOpenGLView);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
inline bool isNextDeltaTimeZero(void) { return m_bNextDeltaTimeZero; }
|
|
|
|
void setNextDeltaTimeZero(bool bNextDeltaTimeZero);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Whether or not the Director is paused */
|
|
|
|
inline bool isPaused(void) { return m_bPaused; }
|
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 */
|
2012-06-14 10:49:53 +08:00
|
|
|
inline unsigned int getTotalFrames(void) { return m_uTotalFrames; }
|
2011-07-08 14:48:25 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Sets an OpenGL projection
|
|
|
|
@since v0.8.2
|
|
|
|
*/
|
|
|
|
inline ccDirectorProjection getProjection(void) { return m_eProjection; }
|
|
|
|
void setProjection(ccDirectorProjection kProjection);
|
2013-02-27 15:44:36 +08:00
|
|
|
|
|
|
|
/** Sets the glViewport*/
|
|
|
|
void setViewport();
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2011-07-08 14:48:25 +08:00
|
|
|
/** How many frames were called since the director started */
|
|
|
|
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** 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.
|
|
|
|
@since v0.99.0
|
|
|
|
*/
|
|
|
|
inline bool isSendCleanupToScene(void) { return m_bSendCleanupToScene; }
|
|
|
|
|
|
|
|
/** This object will be visited after the main scene is visited.
|
|
|
|
This object MUST implement the "visit" selector.
|
|
|
|
Useful to hook a notification object, like CCNotifications (http://github.com/manucorporat/CCNotifications)
|
|
|
|
@since v0.99.5
|
|
|
|
*/
|
|
|
|
CCNode* getNotificationNode();
|
|
|
|
void setNotificationNode(CCNode *node);
|
2012-11-13 11:06:32 +08:00
|
|
|
|
|
|
|
/** CCDirector delegate. It shall implemente the CCDirectorDelegate protocol
|
|
|
|
@since v0.99.5
|
|
|
|
*/
|
|
|
|
CCDirectorDelegate* getDelegate() const;
|
|
|
|
void setDelegate(CCDirectorDelegate* pDelegate);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// window size
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** returns the size of the OpenGL view in points.
|
|
|
|
*/
|
|
|
|
CCSize getWinSize(void);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** returns the size of the OpenGL view in pixels.
|
|
|
|
*/
|
|
|
|
CCSize getWinSizeInPixels(void);
|
2012-08-09 10:23:39 +08:00
|
|
|
|
|
|
|
/** returns visible size of the OpenGL view in points.
|
|
|
|
* the value is equal to getWinSize if don't invoke
|
|
|
|
* CCEGLView::setDesignResolutionSize()
|
|
|
|
*/
|
|
|
|
CCSize getVisibleSize();
|
|
|
|
|
|
|
|
/** returns visible origin of the OpenGL view in points.
|
|
|
|
*/
|
|
|
|
CCPoint getVisibleOrigin();
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** converts a UIKit coordinate to an OpenGL coordinate
|
2012-11-13 11:06:32 +08:00
|
|
|
Useful to convert (multi) touch coordinates to the current layout (portrait or landscape)
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
CCPoint convertToGL(const CCPoint& obPoint);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** converts an OpenGL coordinate to a UIKit coordinate
|
|
|
|
Useful to convert node points to window points for calls such as glScissor
|
|
|
|
*/
|
|
|
|
CCPoint convertToUI(const CCPoint& obPoint);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/// XXX: missing description
|
|
|
|
float getZEye(void);
|
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
|
|
|
|
2013-05-01 06:33:22 +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
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
void runWithScene(CCScene *pScene);
|
|
|
|
|
2013-05-01 06:33:22 +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.
|
|
|
|
*/
|
|
|
|
void pushScene(CCScene *pScene);
|
|
|
|
|
2013-05-01 06:33:22 +08:00
|
|
|
/** Pops out a scene from the queue.
|
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.
|
|
|
|
*/
|
|
|
|
void popScene(void);
|
|
|
|
|
2013-05-01 06:33:22 +08:00
|
|
|
/** Pops out all scenes from the queue until the root scene in the queue.
|
2012-06-12 02:50:32 +08:00
|
|
|
* This scene will replace the running one.
|
2013-05-01 06:33:22 +08:00
|
|
|
* Internally it will call `popToSceneStackLevel(1)`
|
2012-06-12 02:50:32 +08:00
|
|
|
*/
|
2012-06-11 10:59:57 +08:00
|
|
|
void popToRootScene(void);
|
|
|
|
|
2013-05-01 06:33:22 +08:00
|
|
|
/** Pops out all scenes from the queue 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 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.
|
|
|
|
*/
|
|
|
|
void replaceScene(CCScene *pScene);
|
|
|
|
|
|
|
|
/** Ends the execution, releases the running scene.
|
|
|
|
It doesn't remove the OpenGL view from its parent. You have to do it manually.
|
|
|
|
*/
|
|
|
|
void end(void);
|
|
|
|
|
|
|
|
/** 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 pause(void);
|
|
|
|
|
|
|
|
/** 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 resume(void);
|
|
|
|
|
|
|
|
/** 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.
|
|
|
|
*/
|
|
|
|
virtual void stopAnimation(void) = 0;
|
|
|
|
|
|
|
|
/** The main loop is triggered again.
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
virtual void startAnimation(void) = 0;
|
|
|
|
|
|
|
|
/** Draw the scene.
|
|
|
|
This method is called every frame. Don't call it manually.
|
|
|
|
*/
|
|
|
|
void drawScene(void);
|
|
|
|
|
|
|
|
// Memory Helper
|
|
|
|
|
|
|
|
/** Removes cached all cocos2d cached data.
|
|
|
|
It will purge the CCTextureCache, CCSpriteFrameCache, CCLabelBMFont cache
|
|
|
|
@since v0.99.3
|
|
|
|
*/
|
|
|
|
void purgeCachedData(void);
|
|
|
|
|
|
|
|
// OpenGL Helper
|
|
|
|
|
|
|
|
/** sets the OpenGL default values */
|
|
|
|
void setGLDefaultValues(void);
|
|
|
|
|
|
|
|
/** enables/disables OpenGL alpha blending */
|
|
|
|
void setAlphaBlending(bool bOn);
|
|
|
|
|
|
|
|
/** enables/disables OpenGL depth test */
|
|
|
|
void setDepthTest(bool bOn);
|
|
|
|
|
|
|
|
virtual void mainLoop(void) = 0;
|
|
|
|
|
|
|
|
/** 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.
|
|
|
|
@since v0.99.4
|
|
|
|
*/
|
2012-08-01 15:30:12 +08:00
|
|
|
void setContentScaleFactor(float scaleFactor);
|
|
|
|
float getContentScaleFactor(void);
|
2010-12-29 18:01:37 +08:00
|
|
|
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
/** CCScheduler associated with this director
|
|
|
|
@since v2.0
|
|
|
|
*/
|
|
|
|
CC_PROPERTY(CCScheduler*, m_pScheduler, Scheduler);
|
|
|
|
|
|
|
|
/** CCActionManager associated with this director
|
|
|
|
@since v2.0
|
|
|
|
*/
|
|
|
|
CC_PROPERTY(CCActionManager*, m_pActionManager, ActionManager);
|
|
|
|
|
|
|
|
/** CCTouchDispatcher associated with this director
|
|
|
|
@since v2.0
|
|
|
|
*/
|
|
|
|
CC_PROPERTY(CCTouchDispatcher*, m_pTouchDispatcher, TouchDispatcher);
|
|
|
|
|
2013-06-02 10:11:43 +08:00
|
|
|
#ifdef KEYBOARD_SUPPORT
|
2013-05-31 20:29:32 +08:00
|
|
|
/** CCKeyboardDispatcher associated with this director
|
|
|
|
@since v?.?
|
|
|
|
*/
|
|
|
|
CC_PROPERTY(CCKeyboardDispatcher*, m_pKeyboardDispatcher, KeyboardDispatcher);
|
2013-06-02 10:11:43 +08:00
|
|
|
#endif
|
2012-04-19 14:35:52 +08:00
|
|
|
/** CCKeypadDispatcher associated with this director
|
|
|
|
@since v2.0
|
|
|
|
*/
|
|
|
|
CC_PROPERTY(CCKeypadDispatcher*, m_pKeypadDispatcher, KeypadDispatcher);
|
|
|
|
|
|
|
|
/** CCAccelerometer associated with this director
|
|
|
|
@since v2.0
|
|
|
|
*/
|
|
|
|
CC_PROPERTY(CCAccelerometer*, m_pAccelerometer, Accelerometer);
|
|
|
|
|
2013-03-01 13:40:38 +08:00
|
|
|
/* delta time since last tick to main loop */
|
|
|
|
CC_PROPERTY_READONLY(float, m_fDeltaTime, DeltaTime);
|
|
|
|
|
2013-05-23 15:06:57 +08:00
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
/** returns a shared instance of the director */
|
|
|
|
static CCDirector* sharedDirector(void);
|
2010-07-12 17:03:27 +08:00
|
|
|
|
|
|
|
protected:
|
2011-04-11 15:10:09 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void purgeDirector();
|
|
|
|
bool m_bPurgeDirecotorInNextLoop; // this flag will be set to true in end()
|
|
|
|
|
|
|
|
void setNextScene(void);
|
|
|
|
|
2012-04-13 11:22:17 +08:00
|
|
|
void showStats();
|
|
|
|
void createStatsLabel();
|
|
|
|
void calculateMPF();
|
2013-02-27 09:38:30 +08:00
|
|
|
void getFPSImageData(unsigned char** datapointer, unsigned int* length);
|
|
|
|
|
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();
|
|
|
|
protected:
|
2012-04-19 14:35:52 +08:00
|
|
|
/* The CCEGLView, where everything is rendered */
|
2012-04-25 16:18:04 +08:00
|
|
|
CCEGLView *m_pobOpenGLView;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
double m_dAnimationInterval;
|
|
|
|
double m_dOldAnimationInterval;
|
|
|
|
|
|
|
|
/* landscape mode ? */
|
|
|
|
bool m_bLandscape;
|
|
|
|
|
|
|
|
bool m_bDisplayStats;
|
2012-06-12 01:43:07 +08:00
|
|
|
float m_fAccumDt;
|
|
|
|
float m_fFrameRate;
|
2012-04-13 11:22:17 +08:00
|
|
|
|
2013-05-23 15:06:57 +08:00
|
|
|
CCLabelAtlas *m_pFPSLabel;
|
|
|
|
CCLabelAtlas *m_pSPFLabel;
|
|
|
|
CCLabelAtlas *m_pDrawsLabel;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-11 10:59:57 +08:00
|
|
|
/** Whether or not the Director is paused */
|
2012-04-19 14:35:52 +08:00
|
|
|
bool m_bPaused;
|
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 */
|
2012-04-19 14:35:52 +08:00
|
|
|
unsigned int m_uTotalFrames;
|
2011-07-08 14:48:25 +08:00
|
|
|
unsigned int m_uFrames;
|
2012-06-12 01:43:07 +08:00
|
|
|
float m_fSecondsPerFrame;
|
2011-07-08 14:48:25 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/* The running scene */
|
|
|
|
CCScene *m_pRunningScene;
|
|
|
|
|
|
|
|
/* will be the next 'runningScene' in the next frame
|
|
|
|
nextScene is a weak reference. */
|
|
|
|
CCScene *m_pNextScene;
|
|
|
|
|
|
|
|
/* If YES, then "old" scene will receive the cleanup message */
|
|
|
|
bool m_bSendCleanupToScene;
|
|
|
|
|
|
|
|
/* scheduled scenes */
|
|
|
|
CCArray* m_pobScenesStack;
|
|
|
|
|
|
|
|
/* last time the main loop was updated */
|
|
|
|
struct cc_timeval *m_pLastUpdate;
|
|
|
|
|
|
|
|
/* whether or not the next delta time will be zero */
|
|
|
|
bool m_bNextDeltaTimeZero;
|
|
|
|
|
|
|
|
/* projection used */
|
|
|
|
ccDirectorProjection m_eProjection;
|
|
|
|
|
|
|
|
/* window size in points */
|
|
|
|
CCSize m_obWinSizeInPoints;
|
|
|
|
|
|
|
|
/* content scale factor */
|
2012-08-01 15:30:12 +08:00
|
|
|
float m_fContentScaleFactor;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/* store the fps string */
|
|
|
|
char *m_pszFPS;
|
|
|
|
|
|
|
|
/* This object will be visited after the scene. Useful to hook a notification node */
|
|
|
|
CCNode *m_pNotificationNode;
|
|
|
|
|
|
|
|
/* Projection protocol delegate */
|
|
|
|
CCDirectorDelegate *m_pProjectionDelegate;
|
2012-08-07 14:29:46 +08:00
|
|
|
|
|
|
|
// CCEGLViewProtocol will recreate stats labels to fit visible rect
|
|
|
|
friend class CCEGLViewProtocol;
|
2010-08-02 10:58:00 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/**
|
|
|
|
@brief DisplayLinkDirector is a Director that 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
|
|
|
|
|
|
|
|
@since v0.8.2
|
2010-08-02 10:58:00 +08:00
|
|
|
*/
|
|
|
|
class CCDisplayLinkDirector : public CCDirector
|
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
CCDisplayLinkDirector(void)
|
|
|
|
: m_bInvalid(false)
|
|
|
|
{}
|
2010-08-02 10:58:00 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void mainLoop(void);
|
|
|
|
virtual void setAnimationInterval(double dValue);
|
|
|
|
virtual void startAnimation(void);
|
|
|
|
virtual void stopAnimation();
|
2010-08-02 10:58:00 +08:00
|
|
|
|
|
|
|
protected:
|
2012-04-19 14:35:52 +08:00
|
|
|
bool m_bInvalid;
|
2010-08-02 10:58:00 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of base_node group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_END
|
2010-08-02 10:58:00 +08:00
|
|
|
|
|
|
|
#endif // __CCDIRECTOR_H__
|