mirror of https://github.com/axmolengine/axmol.git
issue #1156: remove unneeded macros and functions
This commit is contained in:
parent
7cf16dbb32
commit
028cf7874e
|
@ -99,7 +99,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
// pDirector->enableRetinaDisplay(true);
|
// pDirector->enableRetinaDisplay(true);
|
||||||
|
|
||||||
// turn on display FPS
|
// turn on display FPS
|
||||||
pDirector->setDisplayFPS(true);
|
//pDirector->setDisplayFPS(true);
|
||||||
|
|
||||||
// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,7 @@ THE SOFTWARE.
|
||||||
#include "CCShaderCache.h"
|
#include "CCShaderCache.h"
|
||||||
#include "kazmath/kazmath.h"
|
#include "kazmath/kazmath.h"
|
||||||
#include "kazmath/GL/matrix.h"
|
#include "kazmath/GL/matrix.h"
|
||||||
#if CC_ENABLE_PROFILERS
|
|
||||||
#include "support/CCProfiling.h"
|
#include "support/CCProfiling.h"
|
||||||
#endif // CC_ENABLE_PROFILERS
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -115,7 +113,9 @@ bool CCDirector::init(void)
|
||||||
m_fAccumDt = 0.0f;
|
m_fAccumDt = 0.0f;
|
||||||
m_fFrameRate = 0.0f;
|
m_fFrameRate = 0.0f;
|
||||||
m_pFPSLabel = NULL;
|
m_pFPSLabel = NULL;
|
||||||
m_bDisplayFPS = false;
|
m_pSPFLabel = NULL;
|
||||||
|
m_pDrawsLabel = NULL;
|
||||||
|
m_bDisplayStats = false;
|
||||||
m_uTotalFrames = m_uFrames = 0;
|
m_uTotalFrames = m_uFrames = 0;
|
||||||
m_pszFPS = new char[10];
|
m_pszFPS = new char[10];
|
||||||
m_pLastUpdate = new struct cc_timeval();
|
m_pLastUpdate = new struct cc_timeval();
|
||||||
|
@ -162,9 +162,9 @@ CCDirector::~CCDirector(void)
|
||||||
{
|
{
|
||||||
CCLOG("cocos2d: deallocing %p", this);
|
CCLOG("cocos2d: deallocing %p", this);
|
||||||
|
|
||||||
#if CC_DIRECTOR_FAST_FPS
|
|
||||||
CC_SAFE_RELEASE(m_pFPSLabel);
|
CC_SAFE_RELEASE(m_pFPSLabel);
|
||||||
#endif
|
CC_SAFE_RELEASE(m_pSPFLabel);
|
||||||
|
CC_SAFE_RELEASE(m_pDrawsLabel);
|
||||||
|
|
||||||
CC_SAFE_RELEASE(m_pRunningScene);
|
CC_SAFE_RELEASE(m_pRunningScene);
|
||||||
CC_SAFE_RELEASE(m_pNotificationNode);
|
CC_SAFE_RELEASE(m_pNotificationNode);
|
||||||
|
@ -196,14 +196,6 @@ void CCDirector::setGLDefaultValues(void)
|
||||||
|
|
||||||
// set other opengl default values
|
// set other opengl default values
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
#if CC_DIRECTOR_FAST_FPS
|
|
||||||
if (! m_pFPSLabel)
|
|
||||||
{
|
|
||||||
m_pFPSLabel = CCLabelTTF::labelWithString("00.0", "Arial", 24);
|
|
||||||
m_pFPSLabel->retain();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the SCene
|
// Draw the SCene
|
||||||
|
@ -240,17 +232,11 @@ void CCDirector::drawScene(void)
|
||||||
{
|
{
|
||||||
m_pNotificationNode->visit();
|
m_pNotificationNode->visit();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CC_DIRECTOR_FAST_FPS == 1
|
if (m_bDisplayStats)
|
||||||
if (m_bDisplayFPS)
|
{
|
||||||
{
|
showStats();
|
||||||
showFPS();
|
}
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CC_ENABLE_PROFILERS
|
|
||||||
showProfilers();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
|
@ -262,6 +248,11 @@ void CCDirector::drawScene(void)
|
||||||
{
|
{
|
||||||
m_pobOpenGLView->swapBuffers();
|
m_pobOpenGLView->swapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_bDisplayStats)
|
||||||
|
{
|
||||||
|
calculateMPF();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCDirector::calculateDeltaTime(void)
|
void CCDirector::calculateDeltaTime(void)
|
||||||
|
@ -314,7 +305,15 @@ void CCDirector::setOpenGLView(CC_GLVIEW *pobOpenGLView)
|
||||||
// set size
|
// set size
|
||||||
m_obWinSizeInPoints = m_pobOpenGLView->getSize();
|
m_obWinSizeInPoints = m_pobOpenGLView->getSize();
|
||||||
m_obWinSizeInPixels = CCSizeMake(m_obWinSizeInPoints.width * m_fContentScaleFactor, m_obWinSizeInPoints.height * m_fContentScaleFactor);
|
m_obWinSizeInPixels = CCSizeMake(m_obWinSizeInPoints.width * m_fContentScaleFactor, m_obWinSizeInPoints.height * m_fContentScaleFactor);
|
||||||
setGLDefaultValues();
|
|
||||||
|
createStatsLabel();
|
||||||
|
|
||||||
|
if (m_pobOpenGLView)
|
||||||
|
{
|
||||||
|
setGLDefaultValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK_GL_ERROR_DEBUG();
|
||||||
|
|
||||||
if (m_fContentScaleFactor != 1)
|
if (m_fContentScaleFactor != 1)
|
||||||
{
|
{
|
||||||
|
@ -521,12 +520,6 @@ CCSize CCDirector::getWinSizeInPixels()
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the current frame size
|
|
||||||
CCSize CCDirector::getDisplaySizeInPixels(void)
|
|
||||||
{
|
|
||||||
return m_obWinSizeInPixels;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCDirector::reshapeProjection(const CCSize& newWindowSize)
|
void CCDirector::reshapeProjection(const CCSize& newWindowSize)
|
||||||
{
|
{
|
||||||
CC_UNUSED_PARAM(newWindowSize);
|
CC_UNUSED_PARAM(newWindowSize);
|
||||||
|
@ -652,9 +645,9 @@ void CCDirector::purgeDirector()
|
||||||
|
|
||||||
stopAnimation();
|
stopAnimation();
|
||||||
|
|
||||||
#if CC_DIRECTOR_FAST_FPS
|
|
||||||
CC_SAFE_RELEASE_NULL(m_pFPSLabel);
|
CC_SAFE_RELEASE_NULL(m_pFPSLabel);
|
||||||
#endif
|
CC_SAFE_RELEASE_NULL(m_pSPFLabel);
|
||||||
|
CC_SAFE_RELEASE_NULL(m_pDrawsLabel);
|
||||||
|
|
||||||
CCObject* pProjectionDelegate = (CCObject*)m_pProjectionDelegate;
|
CCObject* pProjectionDelegate = (CCObject*)m_pProjectionDelegate;
|
||||||
CC_SAFE_RELEASE_NULL(pProjectionDelegate);
|
CC_SAFE_RELEASE_NULL(pProjectionDelegate);
|
||||||
|
@ -744,41 +737,69 @@ void CCDirector::resume(void)
|
||||||
m_fDeltaTime = 0;
|
m_fDeltaTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CC_DIRECTOR_FAST_FPS
|
|
||||||
// display the FPS using a LabelAtlas
|
// display the FPS using a LabelAtlas
|
||||||
// updates the FPS every frame
|
// updates the FPS every frame
|
||||||
void CCDirector::showFPS(void)
|
void CCDirector::showStats(void)
|
||||||
{
|
{
|
||||||
m_uFrames++;
|
m_uFrames++;
|
||||||
m_fAccumDt += m_fDeltaTime;
|
m_fAccumDt += m_fDeltaTime;
|
||||||
|
|
||||||
if (m_fAccumDt > CC_DIRECTOR_FPS_INTERVAL)
|
if (m_bDisplayStats)
|
||||||
{
|
{
|
||||||
m_fFrameRate = m_uFrames / m_fAccumDt;
|
if (m_fAccumDt > CC_DIRECTOR_STATS_INTERVAL && m_pFPSLabel && m_pSPFLabel && m_pDrawsLabel)
|
||||||
m_uFrames = 0;
|
{
|
||||||
m_fAccumDt = 0;
|
sprintf(m_pszFPS, "%.3f", m_fSecondsPerFrame);
|
||||||
|
m_pFPSLabel->setString(m_pszFPS);
|
||||||
sprintf(m_pszFPS, "%.1f", m_fFrameRate);
|
|
||||||
m_pFPSLabel->setString(m_pszFPS);
|
m_fFrameRate = m_uFrames / m_fAccumDt;
|
||||||
}
|
m_uFrames = 0;
|
||||||
|
m_fAccumDt = 0;
|
||||||
m_pFPSLabel->draw();
|
|
||||||
|
sprintf(m_pszFPS, "%.1f", m_fFrameRate);
|
||||||
|
m_pFPSLabel->setString(m_pszFPS);
|
||||||
|
|
||||||
|
sprintf(m_pszFPS, "%4d", g_uNumberOfDraws);
|
||||||
|
m_pDrawsLabel->setString(m_pszFPS);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pDrawsLabel->draw();
|
||||||
|
m_pFPSLabel->draw();
|
||||||
|
m_pSPFLabel->draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
g_uNumberOfDraws = 0;
|
||||||
}
|
}
|
||||||
#endif // CC_DIRECTOR_FAST_FPS
|
|
||||||
|
|
||||||
|
void CCDirector::calculateMPF()
|
||||||
void CCDirector::showProfilers()
|
|
||||||
{
|
{
|
||||||
#if CC_ENABLE_PROFILERS
|
struct cc_timeval now;
|
||||||
m_fAccumDtForProfiler += m_fDeltaTime;
|
CCTime::gettimeofdayCocos2d(&now, NULL);
|
||||||
if (m_fAccumDtForProfiler > 1.0f)
|
|
||||||
{
|
m_fSecondsPerFrame = (now.tv_sec - m_pLastUpdate->tv_sec) + (now.tv_usec - m_pLastUpdate->tv_usec) / 1000000.0f;
|
||||||
m_fAccumDtForProfiler = 0;
|
|
||||||
CCProfiler::sharedProfiler()->displayTimers();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCDirector::createStatsLabel()
|
||||||
|
{
|
||||||
|
if( m_pFPSLabel && m_pSPFLabel ) {
|
||||||
|
CCTexture2D *texture = m_pFPSLabel->getTexture();
|
||||||
|
|
||||||
|
m_pFPSLabel->release();
|
||||||
|
m_pSPFLabel->release();
|
||||||
|
CCTextureCache::sharedTextureCache()->removeTexture(texture);
|
||||||
|
m_pFPSLabel = NULL;
|
||||||
|
m_pSPFLabel = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pFPSLabel = CCLabelTTF::labelWithString("00.0", "Arial", 20);
|
||||||
|
m_pSPFLabel = CCLabelTTF::labelWithString("0.000", "Arial", 20);
|
||||||
|
m_pDrawsLabel = CCLabelTTF::labelWithString("000", "Arial", 20);
|
||||||
|
|
||||||
|
m_pDrawsLabel->setPosition(ccpAdd(ccp(0, 34), CC_DIRECTOR_STATS_POSITION));
|
||||||
|
m_pSPFLabel->setPosition(ccpAdd(ccp(0, 17), CC_DIRECTOR_STATS_POSITION));
|
||||||
|
m_pFPSLabel->setPosition(CC_DIRECTOR_STATS_POSITION);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
* mobile platforms specific functions
|
* mobile platforms specific functions
|
||||||
**************************************************/
|
**************************************************/
|
||||||
|
@ -797,16 +818,6 @@ void CCDirector::updateContentScaleFactor()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CCDirector::setDirectorType(ccDirectorType obDirectorType)
|
|
||||||
{
|
|
||||||
CC_UNUSED_PARAM(obDirectorType);
|
|
||||||
// we only support CCDisplayLinkDirector
|
|
||||||
CCDirector::sharedDirector();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CCDirector::enableRetinaDisplay(bool enabled)
|
bool CCDirector::enableRetinaDisplay(bool enabled)
|
||||||
{
|
{
|
||||||
// Already enabled?
|
// Already enabled?
|
||||||
|
@ -839,15 +850,6 @@ bool CCDirector::enableRetinaDisplay(bool enabled)
|
||||||
// release cached texture
|
// release cached texture
|
||||||
CCTextureCache::purgeSharedTextureCache();
|
CCTextureCache::purgeSharedTextureCache();
|
||||||
|
|
||||||
#if CC_DIRECTOR_FAST_FPS
|
|
||||||
if (m_pFPSLabel)
|
|
||||||
{
|
|
||||||
CC_SAFE_RELEASE_NULL(m_pFPSLabel);
|
|
||||||
m_pFPSLabel = CCLabelTTF::labelWithString("00.0", "Arial", 24);
|
|
||||||
m_pFPSLabel->retain();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (m_fContentScaleFactor == 2)
|
if (m_fContentScaleFactor == 2)
|
||||||
{
|
{
|
||||||
m_bRetinaDisplay = true;
|
m_bRetinaDisplay = true;
|
||||||
|
|
|
@ -34,7 +34,7 @@ THE SOFTWARE.
|
||||||
#include "CCArray.h"
|
#include "CCArray.h"
|
||||||
#include "CCGeometry.h"
|
#include "CCGeometry.h"
|
||||||
#include "CCEGLView.h"
|
#include "CCEGLView.h"
|
||||||
#include "CCGL.h"
|
#include "CCGL.h"
|
||||||
#include "kazmath/mat4.h"
|
#include "kazmath/mat4.h"
|
||||||
|
|
||||||
namespace cocos2d {
|
namespace cocos2d {
|
||||||
|
@ -54,66 +54,8 @@ typedef enum {
|
||||||
|
|
||||||
/// Detault projection is 3D projection
|
/// Detault projection is 3D projection
|
||||||
kCCDirectorProjectionDefault = kCCDirectorProjection3D,
|
kCCDirectorProjectionDefault = kCCDirectorProjection3D,
|
||||||
|
|
||||||
// backward compatibility stuff
|
|
||||||
CCDirectorProjection2D = kCCDirectorProjection2D,
|
|
||||||
CCDirectorProjection3D = kCCDirectorProjection3D,
|
|
||||||
CCDirectorProjectionCustom = kCCDirectorProjectionCustom,
|
|
||||||
} ccDirectorProjection;
|
} ccDirectorProjection;
|
||||||
|
|
||||||
/** @typedef ccDirectorType
|
|
||||||
Possible Director Types.
|
|
||||||
@since v0.8.2
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
/** Will use a Director that triggers the main loop from an NSTimer object
|
|
||||||
*
|
|
||||||
* Features and Limitations:
|
|
||||||
* - Integrates OK with UIKit objects
|
|
||||||
* - It the slowest director
|
|
||||||
* - The interval update is customizable from 1 to 60
|
|
||||||
*/
|
|
||||||
kCCDirectorTypeNSTimer,
|
|
||||||
|
|
||||||
/** will use a Director that triggers the main loop from a custom main loop.
|
|
||||||
*
|
|
||||||
* Features and Limitations:
|
|
||||||
* - Faster than NSTimer Director
|
|
||||||
* - It doesn't integrate well with UIKit objects
|
|
||||||
* - The interval update can't be customizable
|
|
||||||
*/
|
|
||||||
kCCDirectorTypeMainLoop,
|
|
||||||
|
|
||||||
/** Will use a Director that triggers the main loop from a thread, but the main loop will be executed on the main thread.
|
|
||||||
*
|
|
||||||
* Features and Limitations:
|
|
||||||
* - Faster than NSTimer Director
|
|
||||||
* - It doesn't integrate well with UIKit objects
|
|
||||||
* - The interval update can't be customizable
|
|
||||||
*/
|
|
||||||
kCCDirectorTypeThreadMainLoop,
|
|
||||||
|
|
||||||
/** Will use a Director that synchronizes timers with the refresh rate of the display.
|
|
||||||
*
|
|
||||||
* Features and Limitations:
|
|
||||||
* - Faster than NSTimer Director
|
|
||||||
* - Only available on 3.1+
|
|
||||||
* - Scheduled timers & drawing are synchronizes with the refresh rate of the display
|
|
||||||
* - Integrates OK with UIKit objects
|
|
||||||
* - The interval update can be 1/60, 1/30, 1/15
|
|
||||||
*/
|
|
||||||
kCCDirectorTypeDisplayLink,
|
|
||||||
|
|
||||||
/** Default director is the NSTimer directory */
|
|
||||||
kCCDirectorTypeDefault = kCCDirectorTypeNSTimer,
|
|
||||||
|
|
||||||
// backward compatibility stuff
|
|
||||||
CCDirectorTypeNSTimer = kCCDirectorTypeNSTimer,
|
|
||||||
CCDirectorTypeMainLoop = kCCDirectorTypeMainLoop,
|
|
||||||
CCDirectorTypeThreadMainLoop = kCCDirectorTypeThreadMainLoop,
|
|
||||||
CCDirectorTypeDisplayLink = kCCDirectorTypeDisplayLink,
|
|
||||||
CCDirectorTypeDefault =kCCDirectorTypeDefault,
|
|
||||||
} ccDirectorType;
|
|
||||||
|
|
||||||
/** @typedef ccDeviceOrientation
|
/** @typedef ccDeviceOrientation
|
||||||
Possible device orientations
|
Possible device orientations
|
||||||
|
@ -140,7 +82,7 @@ class CCScene;
|
||||||
class CCEGLView;
|
class CCEGLView;
|
||||||
class CCDirectorDelegate;
|
class CCDirectorDelegate;
|
||||||
class CCNode;
|
class CCNode;
|
||||||
class CCScheduler;
|
class CCScheduler;
|
||||||
class CCActionManager;
|
class CCActionManager;
|
||||||
class CCTouchDispatcher;
|
class CCTouchDispatcher;
|
||||||
class CCKeypadDispatcher;
|
class CCKeypadDispatcher;
|
||||||
|
@ -184,9 +126,12 @@ public:
|
||||||
virtual void setAnimationInterval(double dValue) = 0;
|
virtual void setAnimationInterval(double dValue) = 0;
|
||||||
|
|
||||||
/** Whether or not to display the FPS on the bottom-left corner */
|
/** Whether or not to display the FPS on the bottom-left corner */
|
||||||
inline bool isDisplayFPS(void) { return m_bDisplayFPS; }
|
inline bool isDisplayStats(void) { return m_bDisplayStats; }
|
||||||
/** Display the FPS on the bottom-left corner */
|
/** Display the FPS on the bottom-left corner */
|
||||||
inline void setDisplayFPS(bool bDisplayFPS) { m_bDisplayFPS = bDisplayFPS; }
|
inline void setDisplayStats(bool bDisplayStats) { m_bDisplayStats = bDisplayStats; }
|
||||||
|
|
||||||
|
/** seconds per frame */
|
||||||
|
inline float getSecondsPerFrame() { return m_fSecondsPerFrame; }
|
||||||
|
|
||||||
/** Get the CCEGLView, where everything is rendered */
|
/** Get the CCEGLView, where everything is rendered */
|
||||||
inline CC_GLVIEW* getOpenGLView(void) { return m_pobOpenGLView; }
|
inline CC_GLVIEW* getOpenGLView(void) { return m_pobOpenGLView; }
|
||||||
|
@ -228,21 +173,13 @@ public:
|
||||||
// window size
|
// window size
|
||||||
|
|
||||||
/** returns the size of the OpenGL view in points.
|
/** returns the size of the OpenGL view in points.
|
||||||
It takes into account any possible rotation (device orientation) of the window
|
|
||||||
*/
|
*/
|
||||||
CCSize getWinSize(void);
|
CCSize getWinSize(void);
|
||||||
|
|
||||||
/** returns the size of the OpenGL view in pixels.
|
/** 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.
|
|
||||||
*/
|
*/
|
||||||
CCSize getWinSizeInPixels(void);
|
CCSize getWinSizeInPixels(void);
|
||||||
|
|
||||||
/** returns the display size of the OpenGL view in pixels.
|
|
||||||
It doesn't take into account any possible rotation of the window.
|
|
||||||
*/
|
|
||||||
CCSize getDisplaySizeInPixels(void);
|
|
||||||
|
|
||||||
/** changes the projection size */
|
/** changes the projection size */
|
||||||
void reshapeProjection(const CCSize& newWindowSize);
|
void reshapeProjection(const CCSize& newWindowSize);
|
||||||
|
|
||||||
|
@ -264,6 +201,8 @@ public:
|
||||||
/**Enters the Director's main loop with the given Scene.
|
/**Enters the Director's main loop with the given Scene.
|
||||||
* Call it to run only your FIRST scene.
|
* Call it to run only your FIRST scene.
|
||||||
* Don't call it if there is already a running scene.
|
* Don't call it if there is already a running scene.
|
||||||
|
*
|
||||||
|
* It will call pushScene: and then it will call startAnimation
|
||||||
*/
|
*/
|
||||||
void runWithScene(CCScene *pScene);
|
void runWithScene(CCScene *pScene);
|
||||||
|
|
||||||
|
@ -344,9 +283,6 @@ public:
|
||||||
|
|
||||||
virtual void mainLoop(void) = 0;
|
virtual void mainLoop(void) = 0;
|
||||||
|
|
||||||
// Profiler
|
|
||||||
void showProfilers(void);
|
|
||||||
|
|
||||||
/** rotates the screen if an orientation different than Portrait is used */
|
/** rotates the screen if an orientation different than Portrait is used */
|
||||||
void applyOrientation(void);
|
void applyOrientation(void);
|
||||||
|
|
||||||
|
@ -371,44 +307,29 @@ public:
|
||||||
bool enableRetinaDisplay(bool enabled);
|
bool enableRetinaDisplay(bool enabled);
|
||||||
bool isRetinaDisplay() { return m_bRetinaDisplay; }
|
bool isRetinaDisplay() { return m_bRetinaDisplay; }
|
||||||
|
|
||||||
/** There are 4 types of Director.
|
|
||||||
- kCCDirectorTypeNSTimer (default)
|
|
||||||
- kCCDirectorTypeMainLoop
|
|
||||||
- kCCDirectorTypeThreadMainLoop
|
|
||||||
- kCCDirectorTypeDisplayLink
|
|
||||||
|
|
||||||
Each Director has it's own benefits, limitations.
|
|
||||||
Now we only support DisplayLink director, so it has not effect.
|
|
||||||
|
|
||||||
This method should be called before any other call to the director.
|
|
||||||
|
|
||||||
@since v0.8.2
|
|
||||||
*/
|
|
||||||
static bool setDirectorType(ccDirectorType obDirectorType);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** CCScheduler associated with this director
|
/** CCScheduler associated with this director
|
||||||
@since v2.0
|
@since v2.0
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(CCScheduler*, m_pScheduler, Scheduler);
|
CC_PROPERTY(CCScheduler*, m_pScheduler, Scheduler);
|
||||||
|
|
||||||
/** CCActionManager associated with this director
|
/** CCActionManager associated with this director
|
||||||
@since v2.0
|
@since v2.0
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(CCActionManager*, m_pActionManager, ActionManager);
|
CC_PROPERTY(CCActionManager*, m_pActionManager, ActionManager);
|
||||||
|
|
||||||
/** CCTouchDispatcher associated with this director
|
/** CCTouchDispatcher associated with this director
|
||||||
@since v2.0
|
@since v2.0
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(CCTouchDispatcher*, m_pTouchDispatcher, TouchDispatcher);
|
CC_PROPERTY(CCTouchDispatcher*, m_pTouchDispatcher, TouchDispatcher);
|
||||||
|
|
||||||
/** CCKeypadDispatcher associated with this director
|
/** CCKeypadDispatcher associated with this director
|
||||||
@since v2.0
|
@since v2.0
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(CCKeypadDispatcher*, m_pKeypadDispatcher, KeypadDispatcher);
|
CC_PROPERTY(CCKeypadDispatcher*, m_pKeypadDispatcher, KeypadDispatcher);
|
||||||
|
|
||||||
/** CCAccelerometer associated with this director
|
/** CCAccelerometer associated with this director
|
||||||
@since v2.0
|
@since v2.0
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(CCAccelerometer*, m_pAccelerometer, Accelerometer);
|
CC_PROPERTY(CCAccelerometer*, m_pAccelerometer, Accelerometer);
|
||||||
|
|
||||||
|
@ -425,14 +346,13 @@ protected:
|
||||||
|
|
||||||
void setNextScene(void);
|
void setNextScene(void);
|
||||||
|
|
||||||
#if CC_DIRECTOR_FAST_FPS
|
void showStats();
|
||||||
/** shows the FPS in the screen */
|
void createStatsLabel();
|
||||||
void showFPS(void);
|
void calculateMPF();
|
||||||
#else
|
|
||||||
void showFPS(void) {}
|
|
||||||
#endif // CC_DIRECTOR_FAST_FPS
|
|
||||||
|
|
||||||
/** calculates delta time since last time it was called */ void calculateDeltaTime();protected:
|
/** calculates delta time since last time it was called */
|
||||||
|
void calculateDeltaTime();
|
||||||
|
protected:
|
||||||
/* The CCEGLView, where everything is rendered */
|
/* The CCEGLView, where everything is rendered */
|
||||||
CC_GLVIEW *m_pobOpenGLView;
|
CC_GLVIEW *m_pobOpenGLView;
|
||||||
|
|
||||||
|
@ -442,12 +362,13 @@ protected:
|
||||||
/* landscape mode ? */
|
/* landscape mode ? */
|
||||||
bool m_bLandscape;
|
bool m_bLandscape;
|
||||||
|
|
||||||
bool m_bDisplayFPS;
|
bool m_bDisplayStats;
|
||||||
ccTime m_fAccumDt;
|
ccTime m_fAccumDt;
|
||||||
ccTime m_fFrameRate;
|
ccTime m_fFrameRate;
|
||||||
#if CC_DIRECTOR_FAST_FPS
|
|
||||||
CCLabelTTF *m_pFPSLabel;
|
CCLabelTTF *m_pFPSLabel;
|
||||||
#endif
|
CCLabelTTF *m_pSPFLabel;
|
||||||
|
CCLabelTTF *m_pDrawsLabel;
|
||||||
|
|
||||||
/* is the running scene paused */
|
/* is the running scene paused */
|
||||||
bool m_bPaused;
|
bool m_bPaused;
|
||||||
|
@ -455,6 +376,7 @@ protected:
|
||||||
/* How many frames were called since the director started */
|
/* How many frames were called since the director started */
|
||||||
unsigned int m_uTotalFrames;
|
unsigned int m_uTotalFrames;
|
||||||
unsigned int m_uFrames;
|
unsigned int m_uFrames;
|
||||||
|
ccTime m_fSecondsPerFrame;
|
||||||
|
|
||||||
/* The running scene */
|
/* The running scene */
|
||||||
CCScene *m_pRunningScene;
|
CCScene *m_pRunningScene;
|
||||||
|
@ -505,10 +427,6 @@ protected:
|
||||||
bool m_bIsContentScaleSupported;
|
bool m_bIsContentScaleSupported;
|
||||||
|
|
||||||
bool m_bRetinaDisplay;
|
bool m_bRetinaDisplay;
|
||||||
|
|
||||||
#if CC_ENABLE_PROFILERS
|
|
||||||
ccTime m_fAccumDtForProfiler;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,28 +76,14 @@ To enabled set it to 1. Disabled by default.
|
||||||
#define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 0
|
#define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @def CC_FONT_LABEL_SUPPORT
|
|
||||||
If enabled, FontLabel will be used to render .ttf files.
|
|
||||||
If the .ttf file is not found, then it will use the standard UIFont class
|
|
||||||
If disabled, the standard UIFont class will be used.
|
|
||||||
|
|
||||||
To disable set it to 0. Enabled by default.
|
|
||||||
|
|
||||||
Only valid for cocos2d-ios. Not supported on cocos2d-mac
|
/** @def CC_DIRECTOR_STATS_POSITION
|
||||||
*/
|
Position of the FPS
|
||||||
#ifndef CC_FONT_LABEL_SUPPORT
|
|
||||||
#define CC_FONT_LABEL_SUPPORT 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @def CC_DIRECTOR_FAST_FPS
|
|
||||||
If enabled, then the FPS will be drawn using CCLabelAtlas (fast rendering).
|
|
||||||
You will need to add the fps_images.png to your project.
|
|
||||||
If disabled, the FPS will be rendered using CCLabel (slow rendering)
|
|
||||||
|
|
||||||
To enable set it to a value different than 0. Enabled by default.
|
Default: 0,0 (bottom-left corner)
|
||||||
*/
|
*/
|
||||||
#ifndef CC_DIRECTOR_FAST_FPS
|
#ifndef CC_DIRECTOR_STATS_POSITION
|
||||||
#define CC_DIRECTOR_FAST_FPS 1
|
#define CC_DIRECTOR_STATS_POSITION ccp(0,0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @def CC_DIRECTOR_FPS_INTERVAL
|
/** @def CC_DIRECTOR_FPS_INTERVAL
|
||||||
|
@ -107,8 +93,8 @@ To enabled set it to 1. Disabled by default.
|
||||||
|
|
||||||
Default value: 0.1f
|
Default value: 0.1f
|
||||||
*/
|
*/
|
||||||
#ifndef CC_DIRECTOR_FPS_INTERVAL
|
#ifndef CC_DIRECTOR_STATS_INTERVAL
|
||||||
#define CC_DIRECTOR_FPS_INTERVAL (0.5f)
|
#define CC_DIRECTOR_STATS_INTERVAL (0.5f)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @def CC_DIRECTOR_FPS_POSITION
|
/** @def CC_DIRECTOR_FPS_POSITION
|
||||||
|
@ -180,16 +166,16 @@ Only valid for cocos2d-mac. Not supported on cocos2d-ios.
|
||||||
#define CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP 0
|
#define CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @def CC_TEXTURE_ATLAS_USE_VAO
|
/** @def CC_TEXTURE_ATLAS_USE_VAO
|
||||||
By default, CCTextureAtlas (used by many cocos2d classes) will use VAO (Vertex Array Objects).
|
By default, CCTextureAtlas (used by many cocos2d classes) will use VAO (Vertex Array Objects).
|
||||||
Apple recommends its usage but they might consume a lot of memory, specially if you use many of them.
|
Apple recommends its usage but they might consume a lot of memory, specially if you use many of them.
|
||||||
So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it.
|
So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it.
|
||||||
|
|
||||||
To disable it set it to 0. Enabled by default.
|
To disable it set it to 0. Enabled by default.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#ifndef CC_TEXTURE_ATLAS_USE_VAO
|
#ifndef CC_TEXTURE_ATLAS_USE_VAO
|
||||||
#define CC_TEXTURE_ATLAS_USE_VAO 1
|
#define CC_TEXTURE_ATLAS_USE_VAO 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @def CC_TEXTURE_NPOT_SUPPORT
|
/** @def CC_TEXTURE_NPOT_SUPPORT
|
||||||
|
|
|
@ -28,11 +28,9 @@ THE SOFTWARE.
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
#if CC_FONT_LABEL_SUPPORT
|
|
||||||
// FontLabel support
|
// FontLabel support
|
||||||
#import "FontLabel/FontManager.h"
|
#import "FontLabel/FontManager.h"
|
||||||
#import "FontLabel/FontLabelStringDrawing.h"
|
#import "FontLabel/FontLabelStringDrawing.h"
|
||||||
#endif// CC_FONT_LABEL_SUPPORT
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -180,7 +180,7 @@ void Effect5::onExit()
|
||||||
{
|
{
|
||||||
EffectAdvanceTextLayer::onExit();
|
EffectAdvanceTextLayer::onExit();
|
||||||
|
|
||||||
CCDirector::sharedDirector()->setProjection(CCDirectorProjection3D);
|
CCDirector::sharedDirector()->setProjection(kCCDirectorProjection3D);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
|
@ -150,12 +150,12 @@ void TMXOrthoTest::onEnter()
|
||||||
{
|
{
|
||||||
TileDemo::onEnter();
|
TileDemo::onEnter();
|
||||||
|
|
||||||
CCDirector::sharedDirector()->setProjection(CCDirectorProjection3D);
|
CCDirector::sharedDirector()->setProjection(kCCDirectorProjection3D);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMXOrthoTest::onExit()
|
void TMXOrthoTest::onExit()
|
||||||
{
|
{
|
||||||
CCDirector::sharedDirector()->setProjection(CCDirectorProjection2D);
|
CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D);
|
||||||
TileDemo::onExit();
|
TileDemo::onExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue