2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
2012-06-12 01:43:07 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2012-04-19 14:35:52 +08:00
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
|
|
|
Copyright (c) 2011 Zynga Inc.
|
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2013-07-19 13:42:45 +08:00
|
|
|
// cocos2d includes
|
|
|
|
#include "CCDirector.h"
|
|
|
|
|
2013-05-23 04:00:34 +08:00
|
|
|
// standard includes
|
|
|
|
#include <string>
|
|
|
|
|
2013-02-27 09:38:30 +08:00
|
|
|
#include "ccFPSImages.h"
|
2013-10-14 14:01:00 +08:00
|
|
|
#include "CCDrawingPrimitives.h"
|
|
|
|
#include "CCNS.h"
|
|
|
|
#include "CCScene.h"
|
|
|
|
#include "CCArray.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "CCScheduler.h"
|
|
|
|
#include "ccMacros.h"
|
2013-10-14 14:01:00 +08:00
|
|
|
#include "CCNotificationCenter.h"
|
|
|
|
#include "CCTransition.h"
|
|
|
|
#include "CCTextureCache.h"
|
|
|
|
#include "CCSpriteFrameCache.h"
|
|
|
|
#include "CCAutoreleasePool.h"
|
2012-07-19 17:22:36 +08:00
|
|
|
#include "platform/CCFileUtils.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "CCApplication.h"
|
2013-10-14 14:01:00 +08:00
|
|
|
#include "CCLabelBMFont.h"
|
|
|
|
#include "CCLabelAtlas.h"
|
|
|
|
#include "CCActionManager.h"
|
|
|
|
#include "CCAnimationCache.h"
|
|
|
|
#include "CCTouch.h"
|
|
|
|
#include "CCEventDispatcher.h"
|
|
|
|
#include "CCUserDefault.h"
|
|
|
|
#include "ccGLStateCache.h"
|
|
|
|
#include "CCShaderCache.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "kazmath/kazmath.h"
|
|
|
|
#include "kazmath/GL/matrix.h"
|
2013-10-14 14:01:00 +08:00
|
|
|
#include "CCProfiling.h"
|
2013-05-23 15:06:57 +08:00
|
|
|
#include "platform/CCImage.h"
|
2012-04-20 15:23:00 +08:00
|
|
|
#include "CCEGLView.h"
|
2013-05-23 04:00:34 +08:00
|
|
|
#include "CCConfiguration.h"
|
2013-10-26 15:04:01 +08:00
|
|
|
#include "CCEventDispatcher.h"
|
2013-10-29 20:25:03 +08:00
|
|
|
#include "CCFontFreeType.h"
|
2013-11-05 01:14:22 +08:00
|
|
|
#include "Renderer.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-08-07 14:29:46 +08:00
|
|
|
/**
|
|
|
|
Position of the FPS
|
|
|
|
|
|
|
|
Default: 0,0 (bottom-left corner)
|
|
|
|
*/
|
|
|
|
#ifndef CC_DIRECTOR_STATS_POSITION
|
2013-07-12 06:24:23 +08:00
|
|
|
#define CC_DIRECTOR_STATS_POSITION Director::getInstance()->getVisibleOrigin()
|
2012-08-07 14:29:46 +08:00
|
|
|
#endif
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
unsigned int g_uNumberOfDraws = 0;
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
2012-09-16 05:19:14 +08:00
|
|
|
// XXX it should be a Director ivar. Move it there once support for multiple directors is added
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// singleton stuff
|
2013-08-08 16:31:44 +08:00
|
|
|
static DisplayLinkDirector *s_SharedDirector = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
#define kDefaultFPS 60 // 60 frames per second
|
|
|
|
extern const char* cocos2dVersion(void);
|
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Director* Director::getInstance()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-09-21 00:29:16 +08:00
|
|
|
if (!s_SharedDirector)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
s_SharedDirector = new DisplayLinkDirector();
|
2012-09-21 00:29:16 +08:00
|
|
|
s_SharedDirector->init();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2012-09-21 00:29:16 +08:00
|
|
|
return s_SharedDirector;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Director::Director(void)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool Director::init(void)
|
2013-06-07 03:23:44 +08:00
|
|
|
{
|
2013-07-08 10:26:53 +08:00
|
|
|
setDefaultValues();
|
2013-06-07 03:23:44 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// scenes
|
2013-08-08 16:31:44 +08:00
|
|
|
_runningScene = nullptr;
|
|
|
|
_nextScene = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
_notificationNode = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
_scenesStack = new Array();
|
2013-08-22 11:12:09 +08:00
|
|
|
_scenesStack->initWithCapacity(15);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// projection delegate if "Custom" projection is used
|
2013-08-08 16:31:44 +08:00
|
|
|
_projectionDelegate = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// FPS
|
2013-06-15 14:03:30 +08:00
|
|
|
_accumDt = 0.0f;
|
|
|
|
_frameRate = 0.0f;
|
2013-08-08 16:31:44 +08:00
|
|
|
_FPSLabel = nullptr;
|
|
|
|
_SPFLabel = nullptr;
|
|
|
|
_drawsLabel = nullptr;
|
2013-06-15 14:03:30 +08:00
|
|
|
_totalFrames = _frames = 0;
|
|
|
|
_FPS = new char[10];
|
2013-07-19 13:42:45 +08:00
|
|
|
_lastUpdate = new struct timeval;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// paused ?
|
2013-06-15 14:03:30 +08:00
|
|
|
_paused = false;
|
2012-06-11 10:59:57 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// purge ?
|
2013-06-15 14:03:30 +08:00
|
|
|
_purgeDirecotorInNextLoop = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-12 14:47:36 +08:00
|
|
|
_winSizeInPoints = Size::ZERO;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
_openGLView = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_contentScaleFactor = 1.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// scheduler
|
2013-06-20 14:13:12 +08:00
|
|
|
_scheduler = new Scheduler();
|
2012-04-19 14:35:52 +08:00
|
|
|
// action manager
|
2013-06-20 14:13:12 +08:00
|
|
|
_actionManager = new ActionManager();
|
2013-07-25 21:04:32 +08:00
|
|
|
_scheduler->scheduleUpdateForTarget(_actionManager, Scheduler::PRIORITY_SYSTEM, false);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-10-26 15:04:01 +08:00
|
|
|
_eventDispatcher = new EventDispatcher();
|
2013-11-07 18:52:36 +08:00
|
|
|
//init TextureCache
|
|
|
|
initTextureCache();
|
2013-10-26 15:04:01 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// create autorelease pool
|
2013-06-20 14:13:12 +08:00
|
|
|
PoolManager::sharedPoolManager()->push();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Director::~Director(void)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-22 11:05:06 +08:00
|
|
|
CCLOGINFO("deallocing Director: %p", this);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_FPSLabel);
|
|
|
|
CC_SAFE_RELEASE(_SPFLabel);
|
|
|
|
CC_SAFE_RELEASE(_drawsLabel);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_runningScene);
|
|
|
|
CC_SAFE_RELEASE(_notificationNode);
|
|
|
|
CC_SAFE_RELEASE(_scenesStack);
|
|
|
|
CC_SAFE_RELEASE(_scheduler);
|
|
|
|
CC_SAFE_RELEASE(_actionManager);
|
2013-10-26 15:04:01 +08:00
|
|
|
CC_SAFE_RELEASE(_eventDispatcher);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// pop the autorelease pool
|
2013-06-20 14:13:12 +08:00
|
|
|
PoolManager::sharedPoolManager()->pop();
|
|
|
|
PoolManager::purgePoolManager();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
// delete _lastUpdate
|
|
|
|
CC_SAFE_DELETE(_lastUpdate);
|
2012-04-19 14:35:52 +08:00
|
|
|
// delete fps string
|
2013-06-15 14:03:30 +08:00
|
|
|
delete []_FPS;
|
2012-09-21 00:29:16 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
s_SharedDirector = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::setDefaultValues(void)
|
2013-06-07 03:23:44 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Configuration *conf = Configuration::getInstance();
|
2013-06-07 03:23:44 +08:00
|
|
|
|
|
|
|
// default FPS
|
|
|
|
double fps = conf->getNumber("cocos2d.x.fps", kDefaultFPS);
|
2013-06-15 14:03:30 +08:00
|
|
|
_oldAnimationInterval = _animationInterval = 1.0 / fps;
|
2013-06-07 03:23:44 +08:00
|
|
|
|
|
|
|
// Display FPS
|
2013-06-15 14:03:30 +08:00
|
|
|
_displayStats = conf->getBool("cocos2d.x.display_fps", false);
|
2013-06-07 03:23:44 +08:00
|
|
|
|
|
|
|
// GL projection
|
2013-09-16 18:01:16 +08:00
|
|
|
const char *projection = conf->getCString("cocos2d.x.gl.projection", "3d");
|
2013-08-08 16:31:44 +08:00
|
|
|
if (strcmp(projection, "3d") == 0)
|
2013-07-26 04:36:19 +08:00
|
|
|
_projection = Projection::_3D;
|
2013-06-07 03:23:44 +08:00
|
|
|
else if (strcmp(projection, "2d") == 0)
|
2013-07-26 04:36:19 +08:00
|
|
|
_projection = Projection::_2D;
|
2013-06-07 03:23:44 +08:00
|
|
|
else if (strcmp(projection, "custom") == 0)
|
2013-07-26 04:36:19 +08:00
|
|
|
_projection = Projection::CUSTOM;
|
2013-06-07 03:23:44 +08:00
|
|
|
else
|
2013-07-20 13:01:27 +08:00
|
|
|
CCASSERT(false, "Invalid projection value");
|
2013-06-07 03:23:44 +08:00
|
|
|
|
|
|
|
// Default pixel format for PNG images with alpha
|
|
|
|
const char *pixel_format = conf->getCString("cocos2d.x.texture.pixel_format_for_png", "rgba8888");
|
2013-08-08 16:31:44 +08:00
|
|
|
if (strcmp(pixel_format, "rgba8888") == 0)
|
2013-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
2013-08-08 16:31:44 +08:00
|
|
|
else if(strcmp(pixel_format, "rgba4444") == 0)
|
2013-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
2013-08-08 16:31:44 +08:00
|
|
|
else if(strcmp(pixel_format, "rgba5551") == 0)
|
2013-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1);
|
2013-06-07 03:23:44 +08:00
|
|
|
|
|
|
|
// PVR v2 has alpha premultiplied ?
|
|
|
|
bool pvr_alpha_premultipled = conf->getBool("cocos2d.x.texture.pvrv2_has_alpha_premultiplied", false);
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D::PVRImagesHavePremultipliedAlpha(pvr_alpha_premultipled);
|
2013-06-07 03:23:44 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::setGLDefaultValues()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// This method SHOULD be called only after openGLView_ was initialized
|
2013-07-20 13:01:27 +08:00
|
|
|
CCASSERT(_openGLView, "opengl view should not be null");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
setAlphaBlending(true);
|
2012-11-22 16:01:30 +08:00
|
|
|
// XXX: Fix me, should enable/disable depth test according the depth format as cocos2d-iphone did
|
|
|
|
// [self setDepthTest: view_.depthFormat];
|
2013-03-05 10:36:32 +08:00
|
|
|
setDepthTest(false);
|
2013-06-15 14:03:30 +08:00
|
|
|
setProjection(_projection);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// set other opengl default values
|
|
|
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
}
|
|
|
|
|
2012-09-15 06:26:38 +08:00
|
|
|
// Draw the Scene
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::drawScene()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// calculate "global" dt
|
|
|
|
calculateDeltaTime();
|
|
|
|
|
2013-07-08 10:26:53 +08:00
|
|
|
if (_openGLView)
|
|
|
|
{
|
|
|
|
_openGLView->pollInputEvents();
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//tick before glClear: issue #533
|
2013-06-15 14:03:30 +08:00
|
|
|
if (! _paused)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_scheduler->update(_deltaTime);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
/* to avoid flickr, nextScene MUST be here: after tick and before draw.
|
|
|
|
XXX: Which bug is this one. It seems that it can't be reproduced with v0.9 */
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_nextScene)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
setNextScene();
|
|
|
|
}
|
|
|
|
|
|
|
|
kmGLPushMatrix();
|
|
|
|
|
|
|
|
// draw the scene
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_runningScene)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_runningScene->visit();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// draw the notifications node
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_notificationNode)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_notificationNode->visit();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_displayStats)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
showStats();
|
|
|
|
}
|
|
|
|
|
2013-11-05 01:14:22 +08:00
|
|
|
Renderer::getInstance()->render();
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
kmGLPopMatrix();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_totalFrames++;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// swap buffers
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_openGLView)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_openGLView->swapBuffers();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_displayStats)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
calculateMPF();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::calculateDeltaTime()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-19 13:42:45 +08:00
|
|
|
struct timeval now;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
if (gettimeofday(&now, nullptr) != 0)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCLOG("error in gettimeofday");
|
2013-06-15 14:03:30 +08:00
|
|
|
_deltaTime = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-11 10:59:57 +08:00
|
|
|
// new delta time. Re-fixed issue #1277
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_nextDeltaTimeZero)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_deltaTime = 0;
|
|
|
|
_nextDeltaTimeZero = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_deltaTime = (now.tv_sec - _lastUpdate->tv_sec) + (now.tv_usec - _lastUpdate->tv_usec) / 1000000.0f;
|
|
|
|
_deltaTime = MAX(0, _deltaTime);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
// If we are debugging our code, prevent big delta time
|
2013-08-08 16:31:44 +08:00
|
|
|
if (_deltaTime > 0.2f)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_deltaTime = 1 / 60.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
*_lastUpdate = now;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2013-06-20 14:13:12 +08:00
|
|
|
float Director::getDeltaTime() const
|
2013-03-02 16:31:19 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _deltaTime;
|
2013-03-02 16:31:19 +08:00
|
|
|
}
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::setOpenGLView(EGLView *pobOpenGLView)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-20 13:01:27 +08:00
|
|
|
CCASSERT(pobOpenGLView, "opengl view should not be null");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_openGLView != pobOpenGLView)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-05-23 04:00:34 +08:00
|
|
|
// Configuration. Gather GPU info
|
2013-07-12 06:24:23 +08:00
|
|
|
Configuration *conf = Configuration::getInstance();
|
2013-05-23 04:00:34 +08:00
|
|
|
conf->gatherGPUInfo();
|
|
|
|
conf->dumpInfo();
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
// EAGLView is not a Object
|
2013-06-15 14:03:30 +08:00
|
|
|
delete _openGLView; // [openGLView_ release]
|
|
|
|
_openGLView = pobOpenGLView;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// set size
|
2013-06-15 14:03:30 +08:00
|
|
|
_winSizeInPoints = _openGLView->getDesignResolutionSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
createStatsLabel();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_openGLView)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
setGLDefaultValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK_GL_ERROR_DEBUG();
|
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
// _touchDispatcher->setDispatchEvents(true);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-07 18:52:36 +08:00
|
|
|
TextureCache* Director::getTextureCache() const
|
|
|
|
{
|
|
|
|
return _textureCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Director::initTextureCache()
|
|
|
|
{
|
|
|
|
#ifdef EMSCRIPTEN
|
|
|
|
_textureCache = new TextureCacheEmscripten();
|
|
|
|
#else
|
|
|
|
_textureCache = new TextureCache();
|
|
|
|
#endif // EMSCRIPTEN
|
|
|
|
}
|
|
|
|
|
|
|
|
void Director::destroyTextureCache()
|
|
|
|
{
|
|
|
|
if (_textureCache)
|
|
|
|
{
|
|
|
|
_textureCache->waitForQuit();
|
|
|
|
CC_SAFE_RELEASE_NULL(_textureCache);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::setViewport()
|
2013-02-27 15:44:36 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_openGLView)
|
2013-02-27 15:52:14 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_openGLView->setViewPortInPoints(0, 0, _winSizeInPoints.width, _winSizeInPoints.height);
|
2013-02-27 15:52:14 +08:00
|
|
|
}
|
2013-02-27 15:44:36 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::setNextDeltaTimeZero(bool bNextDeltaTimeZero)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_nextDeltaTimeZero = bNextDeltaTimeZero;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-26 04:36:19 +08:00
|
|
|
void Director::setProjection(Projection projection)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
Size size = _winSizeInPoints;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-02-27 15:52:14 +08:00
|
|
|
setViewport();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-26 04:36:19 +08:00
|
|
|
switch (projection)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-26 04:36:19 +08:00
|
|
|
case Projection::_2D:
|
2012-04-19 14:35:52 +08:00
|
|
|
kmGLMatrixMode(KM_GL_PROJECTION);
|
|
|
|
kmGLLoadIdentity();
|
|
|
|
kmMat4 orthoMatrix;
|
2013-08-08 16:31:44 +08:00
|
|
|
kmMat4OrthographicProjection(&orthoMatrix, 0, size.width, 0, size.height, -1024, 1024);
|
2012-04-19 14:35:52 +08:00
|
|
|
kmGLMultMatrix(&orthoMatrix);
|
|
|
|
kmGLMatrixMode(KM_GL_MODELVIEW);
|
|
|
|
kmGLLoadIdentity();
|
2013-07-26 04:36:19 +08:00
|
|
|
break;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-26 04:36:19 +08:00
|
|
|
case Projection::_3D:
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
float zeye = this->getZEye();
|
|
|
|
|
|
|
|
kmMat4 matrixPerspective, matrixLookup;
|
|
|
|
|
|
|
|
kmGLMatrixMode(KM_GL_PROJECTION);
|
|
|
|
kmGLLoadIdentity();
|
|
|
|
|
|
|
|
// issue #1334
|
2013-08-08 16:31:44 +08:00
|
|
|
kmMat4PerspectiveProjection(&matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2);
|
2012-06-12 01:43:07 +08:00
|
|
|
// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
kmGLMultMatrix(&matrixPerspective);
|
|
|
|
|
|
|
|
kmGLMatrixMode(KM_GL_MODELVIEW);
|
|
|
|
kmGLLoadIdentity();
|
|
|
|
kmVec3 eye, center, up;
|
2013-08-08 16:31:44 +08:00
|
|
|
kmVec3Fill(&eye, size.width/2, size.height/2, zeye);
|
|
|
|
kmVec3Fill(¢er, size.width/2, size.height/2, 0.0f);
|
|
|
|
kmVec3Fill(&up, 0.0f, 1.0f, 0.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
kmMat4LookAt(&matrixLookup, &eye, ¢er, &up);
|
|
|
|
kmGLMultMatrix(&matrixLookup);
|
2013-07-26 04:36:19 +08:00
|
|
|
break;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-26 04:36:19 +08:00
|
|
|
case Projection::CUSTOM:
|
|
|
|
if (_projectionDelegate)
|
|
|
|
_projectionDelegate->updateProjection();
|
2013-08-08 16:31:44 +08:00
|
|
|
|
2013-07-26 04:36:19 +08:00
|
|
|
break;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-26 04:36:19 +08:00
|
|
|
default:
|
|
|
|
CCLOG("cocos2d: Director: unrecognized projection");
|
|
|
|
break;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-26 04:36:19 +08:00
|
|
|
_projection = projection;
|
2013-07-26 09:42:53 +08:00
|
|
|
GL::setProjectionMatrixDirty();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::purgeCachedData(void)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
LabelBMFont::purgeCachedData();
|
2012-11-13 11:06:32 +08:00
|
|
|
if (s_SharedDirector->getOpenGLView())
|
|
|
|
{
|
2013-07-22 18:13:13 +08:00
|
|
|
SpriteFrameCache::getInstance()->removeUnusedSpriteFrames();
|
2013-11-07 19:11:09 +08:00
|
|
|
_textureCache->removeUnusedTextures();
|
2012-11-13 11:06:32 +08:00
|
|
|
}
|
2013-07-12 06:24:23 +08:00
|
|
|
FileUtils::getInstance()->purgeCachedEntries();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-07 13:01:21 +08:00
|
|
|
float Director::getZEye(void) const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return (_winSizeInPoints.height / 1.1566f);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::setAlphaBlending(bool on)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
if (on)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-26 09:42:53 +08:00
|
|
|
GL::blendFunc(CC_BLEND_SRC, CC_BLEND_DST);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-26 09:42:53 +08:00
|
|
|
GL::blendFunc(GL_ONE, GL_ZERO);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CHECK_GL_ERROR_DEBUG();
|
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::setDepthTest(bool on)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
if (on)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
glClearDepth(1.0f);
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glDepthFunc(GL_LEQUAL);
|
|
|
|
// glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
}
|
|
|
|
CHECK_GL_ERROR_DEBUG();
|
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
static void GLToClipTransform(kmMat4 *transformOut)
|
2012-11-13 11:06:32 +08:00
|
|
|
{
|
|
|
|
kmMat4 projection;
|
|
|
|
kmGLGetMatrix(KM_GL_PROJECTION, &projection);
|
|
|
|
|
|
|
|
kmMat4 modelview;
|
|
|
|
kmGLGetMatrix(KM_GL_MODELVIEW, &modelview);
|
|
|
|
|
|
|
|
kmMat4Multiply(transformOut, &projection, &modelview);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Point Director::convertToGL(const Point& uiPoint)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-11-13 11:06:32 +08:00
|
|
|
kmMat4 transform;
|
|
|
|
GLToClipTransform(&transform);
|
|
|
|
|
|
|
|
kmMat4 transformInv;
|
|
|
|
kmMat4Inverse(&transformInv, &transform);
|
|
|
|
|
|
|
|
// Calculate z=0 using -> transform*[0, 0, 0, 1]/w
|
|
|
|
kmScalar zClip = transform.mat[14]/transform.mat[15];
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Size glSize = _openGLView->getDesignResolutionSize();
|
2012-12-10 18:10:41 +08:00
|
|
|
kmVec3 clipCoord = {2.0f*uiPoint.x/glSize.width - 1.0f, 1.0f - 2.0f*uiPoint.y/glSize.height, zClip};
|
2012-11-13 11:06:32 +08:00
|
|
|
|
|
|
|
kmVec3 glCoord;
|
|
|
|
kmVec3TransformCoord(&glCoord, &clipCoord, &transformInv);
|
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
return Point(glCoord.x, glCoord.y);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Point Director::convertToUI(const Point& glPoint)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-11-13 11:06:32 +08:00
|
|
|
kmMat4 transform;
|
|
|
|
GLToClipTransform(&transform);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-11-13 11:06:32 +08:00
|
|
|
kmVec3 clipCoord;
|
|
|
|
// Need to calculate the zero depth from the transform.
|
|
|
|
kmVec3 glCoord = {glPoint.x, glPoint.y, 0.0};
|
|
|
|
kmVec3TransformCoord(&clipCoord, &glCoord, &transform);
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Size glSize = _openGLView->getDesignResolutionSize();
|
2013-07-12 14:11:55 +08:00
|
|
|
return Point(glSize.width*(clipCoord.x*0.5 + 0.5), glSize.height*(-clipCoord.y*0.5 + 0.5));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-07 13:01:21 +08:00
|
|
|
const Size& Director::getWinSize(void) const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _winSizeInPoints;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-07 13:01:21 +08:00
|
|
|
Size Director::getWinSizeInPixels() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-12 14:30:26 +08:00
|
|
|
return Size(_winSizeInPoints.width * _contentScaleFactor, _winSizeInPoints.height * _contentScaleFactor);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-07 13:01:21 +08:00
|
|
|
Size Director::getVisibleSize() const
|
2012-08-09 10:23:39 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_openGLView)
|
2012-08-09 10:23:39 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _openGLView->getVisibleSize();
|
2012-08-09 10:23:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-12 14:47:36 +08:00
|
|
|
return Size::ZERO;
|
2012-08-09 10:23:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-07 13:01:21 +08:00
|
|
|
Point Director::getVisibleOrigin() const
|
2012-08-09 10:23:39 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_openGLView)
|
2012-08-09 10:23:39 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _openGLView->getVisibleOrigin();
|
2012-08-09 10:23:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-12 14:47:36 +08:00
|
|
|
return Point::ZERO;
|
2012-08-09 10:23:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// scene management
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::runWithScene(Scene *scene)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
CCASSERT(scene != nullptr, "This command can only be used to start the Director. There is already a scene present.");
|
|
|
|
CCASSERT(_runningScene == nullptr, "_runningScene should be null");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
pushScene(scene);
|
2012-04-19 14:35:52 +08:00
|
|
|
startAnimation();
|
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::replaceScene(Scene *scene)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-20 13:01:27 +08:00
|
|
|
CCASSERT(_runningScene, "Use runWithScene: instead to start the director");
|
2013-08-08 16:31:44 +08:00
|
|
|
CCASSERT(scene != nullptr, "the scene should not be null");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
unsigned int index = _scenesStack->count();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_sendCleanupToScene = true;
|
2013-08-08 16:31:44 +08:00
|
|
|
_scenesStack->replaceObjectAtIndex(index - 1, scene);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
_nextScene = scene;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::pushScene(Scene *scene)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
CCASSERT(scene, "the scene should not null");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_sendCleanupToScene = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
_scenesStack->addObject(scene);
|
|
|
|
_nextScene = scene;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::popScene(void)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
CCASSERT(_runningScene != nullptr, "running scene should not null");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_scenesStack->removeLastObject();
|
|
|
|
unsigned int c = _scenesStack->count();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
if (c == 0)
|
|
|
|
{
|
|
|
|
end();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_sendCleanupToScene = true;
|
2013-08-22 10:45:47 +08:00
|
|
|
_nextScene = (Scene*)_scenesStack->getObjectAtIndex(c - 1);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::popToRootScene(void)
|
2013-05-01 06:33:22 +08:00
|
|
|
{
|
|
|
|
popToSceneStackLevel(1);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::popToSceneStackLevel(int level)
|
2012-06-11 10:59:57 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
CCASSERT(_runningScene != nullptr, "A running Scene is needed");
|
|
|
|
int c = static_cast<int>(_scenesStack->count());
|
2012-06-12 02:50:32 +08:00
|
|
|
|
2013-05-01 06:33:22 +08:00
|
|
|
// level 0? -> end
|
|
|
|
if (level == 0)
|
2012-06-12 02:50:32 +08:00
|
|
|
{
|
2013-05-01 06:33:22 +08:00
|
|
|
end();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// current level or lower -> nothing
|
|
|
|
if (level >= c)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// pop stack until reaching desired level
|
|
|
|
while (c > level)
|
2012-06-12 02:50:32 +08:00
|
|
|
{
|
2013-08-22 10:45:47 +08:00
|
|
|
Scene *current = (Scene*)_scenesStack->getLastObject();
|
2013-05-01 06:33:22 +08:00
|
|
|
|
|
|
|
if (current->isRunning())
|
2012-06-12 02:50:32 +08:00
|
|
|
{
|
2013-05-01 06:33:22 +08:00
|
|
|
current->onExitTransitionDidStart();
|
|
|
|
current->onExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
current->cleanup();
|
2013-06-15 14:03:30 +08:00
|
|
|
_scenesStack->removeLastObject();
|
2013-08-08 16:31:44 +08:00
|
|
|
--c;
|
2013-05-01 06:33:22 +08:00
|
|
|
}
|
|
|
|
|
2013-08-22 10:45:47 +08:00
|
|
|
_nextScene = (Scene*)_scenesStack->getLastObject();
|
2013-06-15 14:03:30 +08:00
|
|
|
_sendCleanupToScene = false;
|
2012-06-11 10:59:57 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::end()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_purgeDirecotorInNextLoop = true;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::purgeDirector()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-09-04 01:21:32 +08:00
|
|
|
// cleanup scheduler
|
2012-11-14 18:05:15 +08:00
|
|
|
getScheduler()->unscheduleAll();
|
2012-09-04 01:21:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// don't release the event handlers
|
|
|
|
// They are needed in case the director is run again
|
2013-09-03 18:22:03 +08:00
|
|
|
// _touchDispatcher->removeAllDelegates();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_runningScene)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_runningScene->onExitTransitionDidStart();
|
|
|
|
_runningScene->onExit();
|
|
|
|
_runningScene->cleanup();
|
|
|
|
_runningScene->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
_runningScene = nullptr;
|
|
|
|
_nextScene = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// remove all objects, but don't release it.
|
|
|
|
// runWithScene might be executed after 'end'.
|
2013-06-15 14:03:30 +08:00
|
|
|
_scenesStack->removeAllObjects();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
stopAnimation();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE_NULL(_FPSLabel);
|
|
|
|
CC_SAFE_RELEASE_NULL(_SPFLabel);
|
|
|
|
CC_SAFE_RELEASE_NULL(_drawsLabel);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// purge bitmap cache
|
2013-06-20 14:13:12 +08:00
|
|
|
LabelBMFont::purgeCachedData();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-10-29 20:25:03 +08:00
|
|
|
FontFreeType::shutdownFreeType();
|
|
|
|
|
2012-06-20 11:48:31 +08:00
|
|
|
// purge all managed caches
|
2013-07-25 22:38:55 +08:00
|
|
|
DrawPrimitives::free();
|
2013-07-12 06:24:23 +08:00
|
|
|
AnimationCache::destroyInstance();
|
|
|
|
SpriteFrameCache::destroyInstance();
|
|
|
|
ShaderCache::destroyInstance();
|
|
|
|
FileUtils::destroyInstance();
|
|
|
|
Configuration::destroyInstance();
|
2012-05-23 12:11:53 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// cocos2d-x specific data structures
|
2013-07-12 06:24:23 +08:00
|
|
|
UserDefault::destroyInstance();
|
|
|
|
NotificationCenter::destroyInstance();
|
2013-09-18 13:00:43 +08:00
|
|
|
|
2013-07-26 09:42:53 +08:00
|
|
|
GL::invalidateStateCache();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-07 18:52:36 +08:00
|
|
|
destroyTextureCache();
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CHECK_GL_ERROR_DEBUG();
|
|
|
|
|
|
|
|
// OpenGL view
|
2013-09-18 23:52:09 +08:00
|
|
|
if (_openGLView)
|
|
|
|
{
|
|
|
|
_openGLView->end();
|
|
|
|
_openGLView = nullptr;
|
|
|
|
}
|
2012-09-21 00:29:16 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
// delete Director
|
2012-09-21 00:29:16 +08:00
|
|
|
release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::setNextScene()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
bool runningIsTransition = dynamic_cast<TransitionScene*>(_runningScene) != nullptr;
|
|
|
|
bool newIsTransition = dynamic_cast<TransitionScene*>(_nextScene) != nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// If it is not a transition, call onExit/cleanup
|
|
|
|
if (! newIsTransition)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_runningScene)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_runningScene->onExitTransitionDidStart();
|
|
|
|
_runningScene->onExit();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// issue #709. the root node (scene) should receive the cleanup message too
|
|
|
|
// otherwise it might be leaked.
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_sendCleanupToScene && _runningScene)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_runningScene->cleanup();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_runningScene)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_runningScene->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2013-06-15 14:03:30 +08:00
|
|
|
_runningScene = _nextScene;
|
|
|
|
_nextScene->retain();
|
2013-08-08 16:31:44 +08:00
|
|
|
_nextScene = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if ((! runningIsTransition) && _runningScene)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_runningScene->onEnter();
|
|
|
|
_runningScene->onEnterTransitionDidFinish();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::pause()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_paused)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_oldAnimationInterval = _animationInterval;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// when paused, don't consume CPU
|
|
|
|
setAnimationInterval(1 / 4.0);
|
2013-06-15 14:03:30 +08:00
|
|
|
_paused = true;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::resume()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (! _paused)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
setAnimationInterval(_oldAnimationInterval);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
if (gettimeofday(_lastUpdate, nullptr) != 0)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCLOG("cocos2d: Director: Error in gettimeofday");
|
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_paused = false;
|
|
|
|
_deltaTime = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// display the FPS using a LabelAtlas
|
|
|
|
// updates the FPS every frame
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::showStats()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
++_frames;
|
2013-06-15 14:03:30 +08:00
|
|
|
_accumDt += _deltaTime;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_displayStats)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_FPSLabel && _SPFLabel && _drawsLabel)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_accumDt > CC_DIRECTOR_STATS_INTERVAL)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
sprintf(_FPS, "%.3f", _secondsPerFrame);
|
|
|
|
_SPFLabel->setString(_FPS);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_frameRate = _frames / _accumDt;
|
|
|
|
_frames = 0;
|
|
|
|
_accumDt = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
sprintf(_FPS, "%.1f", _frameRate);
|
|
|
|
_FPSLabel->setString(_FPS);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
sprintf(_FPS, "%4lu", (unsigned long)g_uNumberOfDraws);
|
|
|
|
_drawsLabel->setString(_FPS);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_drawsLabel->visit();
|
|
|
|
_FPSLabel->visit();
|
|
|
|
_SPFLabel->visit();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_uNumberOfDraws = 0;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::calculateMPF()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-19 13:42:45 +08:00
|
|
|
struct timeval now;
|
2013-08-08 16:31:44 +08:00
|
|
|
gettimeofday(&now, nullptr);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_secondsPerFrame = (now.tv_sec - _lastUpdate->tv_sec) + (now.tv_usec - _lastUpdate->tv_usec) / 1000000.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-02-27 09:38:30 +08:00
|
|
|
// returns the FPS image data pointer and len
|
2013-11-06 09:36:44 +08:00
|
|
|
void Director::getFPSImageData(unsigned char** datapointer, long* length)
|
2013-02-27 09:38:30 +08:00
|
|
|
{
|
2013-03-01 09:51:42 +08:00
|
|
|
// XXX fixed me if it should be used
|
2013-05-23 15:06:57 +08:00
|
|
|
*datapointer = cc_fps_images_png;
|
|
|
|
*length = cc_fps_images_len();
|
2013-02-27 09:38:30 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::createStatsLabel()
|
2013-05-23 15:06:57 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
Texture2D *texture = nullptr;
|
2013-05-23 15:11:48 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
if (_FPSLabel && _SPFLabel)
|
2012-06-12 02:50:32 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE_NULL(_FPSLabel);
|
|
|
|
CC_SAFE_RELEASE_NULL(_SPFLabel);
|
|
|
|
CC_SAFE_RELEASE_NULL(_drawsLabel);
|
2013-11-11 14:21:41 +08:00
|
|
|
_textureCache->removeTextureForKey("/cc_fps_images");
|
2013-07-12 06:24:23 +08:00
|
|
|
FileUtils::getInstance()->purgeCachedEntries();
|
2012-06-12 02:50:32 +08:00
|
|
|
}
|
|
|
|
|
2013-07-25 19:52:44 +08:00
|
|
|
Texture2D::PixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat();
|
2013-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
2013-08-08 16:31:44 +08:00
|
|
|
unsigned char *data = nullptr;
|
2013-11-06 09:36:44 +08:00
|
|
|
long dataLength = 0;
|
2013-08-08 16:31:44 +08:00
|
|
|
getFPSImageData(&data, &dataLength);
|
2013-05-23 15:11:48 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Image* image = new Image();
|
2013-08-08 16:31:44 +08:00
|
|
|
bool isOK = image->initWithImageData(data, dataLength);
|
|
|
|
if (! isOK) {
|
2013-05-23 15:06:57 +08:00
|
|
|
CCLOGERROR("%s", "Fails: init fps_images");
|
|
|
|
return;
|
2012-10-23 10:50:47 +08:00
|
|
|
}
|
2013-05-23 15:11:48 +08:00
|
|
|
|
2013-11-11 14:21:41 +08:00
|
|
|
texture = _textureCache->addImage(image, "/cc_fps_images");
|
2013-05-23 15:06:57 +08:00
|
|
|
CC_SAFE_RELEASE(image);
|
2013-05-23 15:11:48 +08:00
|
|
|
|
2013-05-23 16:55:53 +08:00
|
|
|
/*
|
|
|
|
We want to use an image which is stored in the file named ccFPSImage.c
|
|
|
|
for any design resolutions and all resource resolutions.
|
|
|
|
|
|
|
|
To achieve this,
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Firstly, we need to ignore 'contentScaleFactor' in 'AtlasNode' and 'LabelAtlas'.
|
|
|
|
So I added a new method called 'setIgnoreContentScaleFactor' for 'AtlasNode',
|
2013-05-23 16:55:53 +08:00
|
|
|
this is not exposed to game developers, it's only used for displaying FPS now.
|
|
|
|
|
|
|
|
Secondly, the size of this image is 480*320, to display the FPS label with correct size,
|
|
|
|
a factor of design resolution ratio of 480x320 is also needed.
|
|
|
|
*/
|
2013-07-12 13:11:21 +08:00
|
|
|
float factor = EGLView::getInstance()->getDesignResolutionSize().height / 320.0f;
|
2013-05-23 15:11:48 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
_FPSLabel = new LabelAtlas();
|
2013-06-15 14:03:30 +08:00
|
|
|
_FPSLabel->setIgnoreContentScaleFactor(true);
|
|
|
|
_FPSLabel->initWithString("00.0", texture, 12, 32 , '.');
|
|
|
|
_FPSLabel->setScale(factor);
|
2013-05-23 15:11:48 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
_SPFLabel = new LabelAtlas();
|
2013-06-15 14:03:30 +08:00
|
|
|
_SPFLabel->setIgnoreContentScaleFactor(true);
|
|
|
|
_SPFLabel->initWithString("0.000", texture, 12, 32, '.');
|
|
|
|
_SPFLabel->setScale(factor);
|
2013-05-23 15:11:48 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
_drawsLabel = new LabelAtlas();
|
2013-06-15 14:03:30 +08:00
|
|
|
_drawsLabel->setIgnoreContentScaleFactor(true);
|
|
|
|
_drawsLabel->initWithString("000", texture, 12, 32, '.');
|
|
|
|
_drawsLabel->setScale(factor);
|
2013-05-23 15:11:48 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(currentFormat);
|
2013-05-23 15:11:48 +08:00
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
_drawsLabel->setPosition(Point(0, 34*factor) + CC_DIRECTOR_STATS_POSITION);
|
|
|
|
_SPFLabel->setPosition(Point(0, 17*factor) + CC_DIRECTOR_STATS_POSITION);
|
2013-06-15 14:03:30 +08:00
|
|
|
_FPSLabel->setPosition(CC_DIRECTOR_STATS_POSITION);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
float Director::getContentScaleFactor() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _contentScaleFactor;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::setContentScaleFactor(float scaleFactor)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (scaleFactor != _contentScaleFactor)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_contentScaleFactor = scaleFactor;
|
2012-10-23 10:50:47 +08:00
|
|
|
createStatsLabel();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Node* Director::getNotificationNode()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _notificationNode;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Director::setNotificationNode(Node *node)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_notificationNode);
|
|
|
|
_notificationNode = node;
|
|
|
|
CC_SAFE_RETAIN(_notificationNode);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
DirectorDelegate* Director::getDelegate() const
|
2012-11-13 11:06:32 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _projectionDelegate;
|
2012-11-13 11:06:32 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::setDelegate(DirectorDelegate* delegate)
|
2012-11-13 11:06:32 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
_projectionDelegate = delegate;
|
2012-11-13 11:06:32 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::setScheduler(Scheduler* scheduler)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
if (_scheduler != scheduler)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
CC_SAFE_RETAIN(scheduler);
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_scheduler);
|
2013-08-08 16:31:44 +08:00
|
|
|
_scheduler = scheduler;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-23 15:19:26 +08:00
|
|
|
Scheduler* Director::getScheduler() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _scheduler;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void Director::setActionManager(ActionManager* actionManager)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
if (_actionManager != actionManager)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
CC_SAFE_RETAIN(actionManager);
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_actionManager);
|
2013-08-08 16:31:44 +08:00
|
|
|
_actionManager = actionManager;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-23 15:19:26 +08:00
|
|
|
ActionManager* Director::getActionManager() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _actionManager;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-10-26 15:04:01 +08:00
|
|
|
EventDispatcher* Director::getEventDispatcher() const
|
|
|
|
{
|
|
|
|
return _eventDispatcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Director::setEventDispatcher(EventDispatcher* dispatcher)
|
|
|
|
{
|
|
|
|
if (_eventDispatcher != dispatcher)
|
|
|
|
{
|
|
|
|
CC_SAFE_RETAIN(dispatcher);
|
|
|
|
CC_SAFE_RELEASE(_eventDispatcher);
|
|
|
|
_eventDispatcher = dispatcher;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/***************************************************
|
|
|
|
* implementation of DisplayLinkDirector
|
|
|
|
**************************************************/
|
|
|
|
|
2012-09-15 06:26:38 +08:00
|
|
|
// should we implement 4 types of director ??
|
2012-04-19 14:35:52 +08:00
|
|
|
// I think DisplayLinkDirector is enough
|
|
|
|
// so we now only support DisplayLinkDirector
|
2013-08-08 16:31:44 +08:00
|
|
|
void DisplayLinkDirector::startAnimation()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
if (gettimeofday(_lastUpdate, nullptr) != 0)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCLOG("cocos2d: DisplayLinkDirector: Error on gettimeofday");
|
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_invalid = false;
|
2013-04-20 09:15:54 +08:00
|
|
|
#ifndef EMSCRIPTEN
|
2013-07-15 16:24:42 +08:00
|
|
|
Application::getInstance()->setAnimationInterval(_animationInterval);
|
2013-04-20 09:15:54 +08:00
|
|
|
#endif // EMSCRIPTEN
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void DisplayLinkDirector::mainLoop()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_purgeDirecotorInNextLoop)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_purgeDirecotorInNextLoop = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
purgeDirector();
|
|
|
|
}
|
2013-06-15 14:03:30 +08:00
|
|
|
else if (! _invalid)
|
2013-08-08 16:31:44 +08:00
|
|
|
{
|
|
|
|
drawScene();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
// release the objects
|
|
|
|
PoolManager::sharedPoolManager()->pop();
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void DisplayLinkDirector::stopAnimation()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_invalid = true;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
void DisplayLinkDirector::setAnimationInterval(double value)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-08 16:31:44 +08:00
|
|
|
_animationInterval = value;
|
2013-06-15 14:03:30 +08:00
|
|
|
if (! _invalid)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
stopAnimation();
|
|
|
|
startAnimation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|