Merge pull request #3139 from dumganhar/iss2397-getInstance

Merge PR https://github.com/cocos2d/cocos2d-x/pull/3136
This commit is contained in:
James Chen 2013-07-12 01:27:44 -07:00
commit b74f286ea6
436 changed files with 2557 additions and 2242 deletions

View File

@ -50,7 +50,7 @@ namespace CocosDenshion {
static std::string getFullPathWithoutAssetsPrefix(const char* pszFilename)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilename);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilename);
// Removing `assets` since it isn't needed for the API of playing sound.
size_t pos = fullPath.find("assets/");
if (pos == 0)

View File

@ -177,14 +177,14 @@ void SimpleAudioEngine::end()
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
static_preloadBackgroundMusic(fullPath.c_str());
}
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
static_playBackgroundMusic(fullPath.c_str(), bLoop);
}
@ -242,7 +242,7 @@ unsigned int SimpleAudioEngine::playEffect(const char *pszFilePath, bool bLoop,
float pitch, float pan, float gain)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
return static_playEffect(fullPath.c_str(), bLoop, pitch, pan, gain);
}
@ -254,14 +254,14 @@ void SimpleAudioEngine::stopEffect(unsigned int nSoundId)
void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
static_preloadEffect(fullPath.c_str());
}
void SimpleAudioEngine::unloadEffect(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
static_unloadEffect(fullPath.c_str());
}

View File

@ -32,7 +32,7 @@ void SimpleAudioEngine::end() {
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath,
bool bLoop) {
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
oAudioPlayer->playBackgroundMusic(fullPath.c_str(), bLoop);
}
@ -62,7 +62,7 @@ bool SimpleAudioEngine::isBackgroundMusicPlaying() {
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) {
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
return oAudioPlayer->preloadBackgroundMusic(fullPath.c_str());
}
@ -73,7 +73,7 @@ void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) {
unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop,
float pitch, float pan, float gain) {
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
return oAudioPlayer->playEffect(fullPath.c_str(), bLoop, pitch, pan, gain);
}
@ -83,13 +83,13 @@ void SimpleAudioEngine::stopEffect(unsigned int nSoundId) {
void SimpleAudioEngine::preloadEffect(const char* pszFilePath) {
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
return oAudioPlayer->preloadEffect(fullPath.c_str());
}
void SimpleAudioEngine::unloadEffect(const char* pszFilePath) {
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
return oAudioPlayer->unloadEffect(fullPath.c_str());
}

View File

@ -177,14 +177,14 @@ void SimpleAudioEngine::end()
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
static_preloadBackgroundMusic(fullPath.c_str());
}
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
static_playBackgroundMusic(fullPath.c_str(), bLoop);
}
@ -242,7 +242,7 @@ unsigned int SimpleAudioEngine::playEffect(const char *pszFilePath, bool bLoop,
float pitch, float pan, float gain)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
return static_playEffect(fullPath.c_str(), bLoop, pitch, pan, gain);
}
@ -254,14 +254,14 @@ void SimpleAudioEngine::stopEffect(unsigned int nSoundId)
void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
static_preloadEffect(fullPath.c_str());
}
void SimpleAudioEngine::unloadEffect(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
static_unloadEffect(fullPath.c_str());
}

View File

@ -105,7 +105,7 @@ namespace CocosDenshion
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
s3eFile *fileHandle = s3eFileOpen(fullPath.c_str(), "rb");
IwAssertMsg(GAME, fileHandle, ("Open file %s Failed. s3eFileError Code : %i", fullPath.c_str(), s3eFileGetError()));
@ -120,7 +120,7 @@ namespace CocosDenshion
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
s3eResult result;
result = s3eAudioPlayFromBuffer(g_AudioBuffer, g_AudioFileSize, bLoop ? 0 : 1);
@ -198,7 +198,7 @@ namespace CocosDenshion
float pitch, float pan, float gain)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
SoundFxMap::iterator it = g_pSoundFxMap->find(fullPath) ;
@ -228,7 +228,7 @@ namespace CocosDenshion
void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
SoundFxMap::iterator it = g_pSoundFxMap->find(fullPath) ;
if( it==g_pSoundFxMap->end() ) {
s3eFile *fileHandle = s3eFileOpen(fullPath.c_str(), "rb");
@ -248,7 +248,7 @@ namespace CocosDenshion
void SimpleAudioEngine::unloadEffect(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
// effect must not be playing!
SoundFxMap::iterator it = g_pSoundFxMap->find(fullPath) ;

View File

@ -204,7 +204,7 @@ namespace CocosDenshion
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
BackgroundMusicsMap::const_iterator it = s_backgroundMusics.find(fullPath);
if (it == s_backgroundMusics.end())
@ -244,7 +244,7 @@ namespace CocosDenshion
stopBackgroundMusic(false);
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
BackgroundMusicsMap::const_iterator it = s_backgroundMusics.find(fullPath);
if (it == s_backgroundMusics.end())
@ -358,7 +358,7 @@ namespace CocosDenshion
unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop,
float pitch, float pan, float gain)
{
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
EffectsMap::iterator iter = s_effects.find(fullPath);
@ -402,7 +402,7 @@ namespace CocosDenshion
void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
EffectsMap::iterator iter = s_effects.find(fullPath);
@ -453,7 +453,7 @@ namespace CocosDenshion
void SimpleAudioEngine::unloadEffect(const char* pszFilePath)
{
// Changing file path to full path
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
EffectsMap::iterator iter = s_effects.find(fullPath);

View File

@ -259,7 +259,7 @@ void SimpleAudioEngine::setEffectsVolume(float volume)
static std::string _FullPath(const char * szPath)
{
return FileUtils::sharedFileUtils()->fullPathForFilename(szPath);
return FileUtils::getInstance()->fullPathForFilename(szPath);
}
unsigned int _Hash(const char *key)

View File

@ -147,7 +147,7 @@ void Configuration::gatherGPUInfo()
CHECK_GL_ERROR_DEBUG();
}
Configuration* Configuration::sharedConfiguration(void)
Configuration* Configuration::getInstance()
{
if (! s_gSharedConfiguration)
{
@ -158,11 +158,24 @@ Configuration* Configuration::sharedConfiguration(void)
return s_gSharedConfiguration;
}
void Configuration::purgeConfiguration(void)
void Configuration::destroyInstance()
{
CC_SAFE_RELEASE_NULL(s_gSharedConfiguration);
}
// XXX: deprecated
Configuration* Configuration::sharedConfiguration(void)
{
return Configuration::getInstance();
}
// XXX: deprecated
void Configuration::purgeConfiguration(void)
{
Configuration::destroyInstance();
}
bool Configuration::checkForGLExtension(const string &searchName) const
{
bool bRet = false;

View File

@ -56,10 +56,16 @@ class CC_DLL Configuration : public Object
{
public:
/** returns a shared instance of Configuration */
static Configuration *sharedConfiguration(void);
static Configuration *getInstance();
/** purge the shared instance of Configuration */
static void purgeConfiguration(void);
static void destroyInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Configuration *sharedConfiguration(void);
/** @deprecated Use destroyInstance() instead */
CC_DEPRECATED_ATTRIBUTE static void purgeConfiguration(void);
public:

View File

@ -73,7 +73,7 @@ THE SOFTWARE.
Default: 0,0 (bottom-left corner)
*/
#ifndef CC_DIRECTOR_STATS_POSITION
#define CC_DIRECTOR_STATS_POSITION Director::sharedDirector()->getVisibleOrigin()
#define CC_DIRECTOR_STATS_POSITION Director::getInstance()->getVisibleOrigin()
#endif
using namespace std;
@ -89,7 +89,7 @@ static DisplayLinkDirector *s_SharedDirector = NULL;
#define kDefaultFPS 60 // 60 frames per second
extern const char* cocos2dVersion(void);
Director* Director::sharedDirector(void)
Director* Director::getInstance()
{
if (!s_SharedDirector)
{
@ -100,6 +100,12 @@ Director* Director::sharedDirector(void)
return s_SharedDirector;
}
// XXX: deprecated
Director* Director::sharedDirector()
{
return Director::getInstance();
}
Director::Director(void)
{
@ -199,7 +205,7 @@ Director::~Director(void)
void Director::setDefaultValues(void)
{
Configuration *conf = Configuration::sharedConfiguration();
Configuration *conf = Configuration::getInstance();
// default FPS
double fps = conf->getNumber("cocos2d.x.fps", kDefaultFPS);
@ -348,7 +354,7 @@ void Director::setOpenGLView(EGLView *pobOpenGLView)
if (_openGLView != pobOpenGLView)
{
// Configuration. Gather GPU info
Configuration *conf = Configuration::sharedConfiguration();
Configuration *conf = Configuration::getInstance();
conf->gatherGPUInfo();
conf->dumpInfo();
@ -453,9 +459,9 @@ void Director::purgeCachedData(void)
LabelBMFont::purgeCachedData();
if (s_SharedDirector->getOpenGLView())
{
TextureCache::sharedTextureCache()->removeUnusedTextures();
TextureCache::getInstance()->removeUnusedTextures();
}
FileUtils::sharedFileUtils()->purgeCachedEntries();
FileUtils::getInstance()->purgeCachedEntries();
}
float Director::getZEye(void) const
@ -706,16 +712,16 @@ void Director::purgeDirector()
// purge all managed caches
ccDrawFree();
AnimationCache::purgeSharedAnimationCache();
SpriteFrameCache::purgeSharedSpriteFrameCache();
TextureCache::purgeSharedTextureCache();
ShaderCache::purgeSharedShaderCache();
FileUtils::purgeFileUtils();
Configuration::purgeConfiguration();
AnimationCache::destroyInstance();
SpriteFrameCache::destroyInstance();
TextureCache::destroyInstance();
ShaderCache::destroyInstance();
FileUtils::destroyInstance();
Configuration::destroyInstance();
// cocos2d-x specific data structures
UserDefault::purgeSharedUserDefault();
NotificationCenter::purgeNotificationCenter();
UserDefault::destroyInstance();
NotificationCenter::destroyInstance();
ccGLInvalidateStateCache();
@ -853,7 +859,7 @@ void Director::getFPSImageData(unsigned char** datapointer, unsigned int* length
void Director::createStatsLabel()
{
Texture2D *texture = NULL;
TextureCache *textureCache = TextureCache::sharedTextureCache();
TextureCache *textureCache = TextureCache::getInstance();
if( _FPSLabel && _SPFLabel )
{
@ -861,7 +867,7 @@ void Director::createStatsLabel()
CC_SAFE_RELEASE_NULL(_SPFLabel);
CC_SAFE_RELEASE_NULL(_drawsLabel);
textureCache->removeTextureForKey("cc_fps_images");
FileUtils::sharedFileUtils()->purgeCachedEntries();
FileUtils::getInstance()->purgeCachedEntries();
}
Texture2DPixelFormat currentFormat = Texture2D::defaultAlphaPixelFormat();
@ -893,7 +899,7 @@ void Director::createStatsLabel()
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.
*/
float factor = EGLView::sharedOpenGLView()->getDesignResolutionSize().height / 320.0f;
float factor = EGLView::getInstance()->getDesignResolutionSize().height / 320.0f;
_FPSLabel = new LabelAtlas();
_FPSLabel->setIgnoreContentScaleFactor(true);

View File

@ -87,7 +87,7 @@ and when to execute the Scenes.
- setting the orientation (default one is Portrait)
Since the Director is a singleton, the standard way to use it is by calling:
_ Director::sharedDirector()->methodName();
_ Director::getInstance()->methodName();
The Director also sets the default OpenGL context:
- GL_TEXTURE_2D is enabled
@ -347,7 +347,10 @@ public:
public:
/** returns a shared instance of the director */
static Director* sharedDirector(void);
static Director* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Director* sharedDirector(void);
protected:

View File

@ -217,7 +217,7 @@ void Timer::update(float dt)
if (!_runForever && _timesExecuted > _repeat)
{ //unschedule timer
Director::sharedDirector()->getScheduler()->unscheduleSelector(_selector, _target);
Director::getInstance()->getScheduler()->unscheduleSelector(_selector, _target);
}
}
}

View File

@ -208,7 +208,7 @@ bool Follow::initWithTarget(Node *pFollowedNode, const Rect& rect/* = RectZero*/
_boundaryFullyCovered = false;
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
_fullScreenSize = CCPointMake(winSize.width, winSize.height);
_halfScreenSize = ccpMult(_fullScreenSize, 0.5f);

View File

@ -900,7 +900,7 @@ SplitRows* SplitRows::clone() const
void SplitRows::startWithTarget(Node *pTarget)
{
TiledGrid3DAction::startWithTarget(pTarget);
_winSize = Director::sharedDirector()->getWinSizeInPixels();
_winSize = Director::getInstance()->getWinSizeInPixels();
}
void SplitRows::update(float time)
@ -965,7 +965,7 @@ SplitCols* SplitCols::clone() const
void SplitCols::startWithTarget(Node *pTarget)
{
TiledGrid3DAction::startWithTarget(pTarget);
_winSize = Director::sharedDirector()->getWinSizeInPixels();
_winSize = Director::getInstance()->getWinSizeInPixels();
}
void SplitCols::update(float time)

View File

@ -77,7 +77,7 @@ AtlasNode * AtlasNode::create(const char *tile, unsigned int tileWidth, unsigned
bool AtlasNode::initWithTileFile(const char *tile, unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender)
{
CCAssert(tile != NULL, "title should not be null");
Texture2D *texture = TextureCache::sharedTextureCache()->addImage(tile);
Texture2D *texture = TextureCache::getInstance()->addImage(tile);
return initWithTexture(texture, tileWidth, tileHeight, itemsToRender);
}
@ -110,7 +110,7 @@ bool AtlasNode::initWithTexture(Texture2D* texture, unsigned int tileWidth, unsi
_quadsToDraw = itemsToRender;
// shader stuff
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTexture_uColor));
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTexture_uColor));
_uniformColor = glGetUniformLocation( getShaderProgram()->getProgram(), "u_color");
return true;

View File

@ -93,7 +93,7 @@ Node::Node(void)
, _componentContainer(NULL)
{
// set default scheduler and actionManager
Director *director = Director::sharedDirector();
Director *director = Director::getInstance();
_actionManager = director->getActionManager();
_actionManager->retain();
_scheduler = director->getScheduler();
@ -1304,7 +1304,7 @@ Point Node::convertToWorldSpaceAR(const Point& nodePoint)
Point Node::convertToWindowSpace(const Point& nodePoint)
{
Point worldPoint = this->convertToWorldSpace(nodePoint);
return Director::sharedDirector()->convertToUI(worldPoint);
return Director::getInstance()->convertToUI(worldPoint);
}
// convenience methods which take a Touch instead of Point

View File

@ -280,7 +280,7 @@ public:
* The original point (0,0) is at the left-bottom corner of screen.
* For example, this codesnip sets the node in the center of screen.
* @code
* Size size = Director::sharedDirector()->getWinSize();
* Size size = Director::getInstance()->getWinSize();
* node->setPosition( ccp(size.width/2, size.height/2) )
* @endcode
*
@ -826,7 +826,7 @@ public:
* Since v2.0, each rendering node must set its shader program.
* It should be set in initialize phase.
* @code
* node->setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTextureColor));
* node->setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
* @endcode
*
* @param The shader program which fetchs from ShaderCache.

View File

@ -133,7 +133,7 @@ Array* Array::createWithContentsOfFile(const char* pFileName)
Array* Array::createWithContentsOfFileThreadSafe(const char* pFileName)
{
return FileUtils::sharedFileUtils()->createArrayWithContentsOfFile(pFileName);
return FileUtils::getInstance()->createArrayWithContentsOfFile(pFileName);
}
bool Array::init()

View File

@ -373,7 +373,7 @@ Dictionary* Dictionary::createWithDictionary(Dictionary* srcDict)
Dictionary* Dictionary::createWithContentsOfFileThreadSafe(const char *pFileName)
{
return FileUtils::sharedFileUtils()->createDictionaryWithContentsOfFile(pFileName);
return FileUtils::getInstance()->createDictionaryWithContentsOfFile(pFileName);
}
void Dictionary::acceptVisitor(DataVisitor &visitor)
@ -390,7 +390,7 @@ Dictionary* Dictionary::createWithContentsOfFile(const char *pFileName)
bool Dictionary::writeToFile(const char *fullPath)
{
return FileUtils::sharedFileUtils()->writeToFile(this, fullPath);
return FileUtils::getInstance()->writeToFile(this, fullPath);
}
Dictionary* Dictionary::clone() const

View File

@ -209,7 +209,7 @@ String* String::createWithContentsOfFile(const char* pszFileName)
unsigned long size = 0;
unsigned char* pData = 0;
String* pRet = NULL;
pData = FileUtils::sharedFileUtils()->getFileData(pszFileName, "rb", &size);
pData = FileUtils::getInstance()->getFileData(pszFileName, "rb", &size);
pRet = String::createWithData(pData, size);
CC_SAFE_DELETE_ARRAY(pData);
return pRet;

View File

@ -149,7 +149,7 @@ bool DrawNode::init()
_blendFunc.src = CC_BLEND_SRC;
_blendFunc.dst = CC_BLEND_DST;
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionLengthTexureColor));
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionLengthTexureColor));
ensureCapacity(512);

View File

@ -94,7 +94,7 @@ static void lazy_init( void )
//
// Position and 1 color passed as a uniform (to simulate glColor4ub )
//
s_pShader = ShaderCache::sharedShaderCache()->programForKey(kShader_Position_uColor);
s_pShader = ShaderCache::getInstance()->programForKey(kShader_Position_uColor);
s_pShader->retain();
s_nColorLocation = glGetUniformLocation( s_pShader->getProgram(), "u_color");

View File

@ -103,7 +103,7 @@ bool GridBase::initWithSize(const Size& gridSize, Texture2D *pTexture, bool bFli
bRet = false;
}
_shaderProgram = ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTexture);
_shaderProgram = ShaderCache::getInstance()->programForKey(kShader_PositionTexture);
calculateVertexPoints();
return bRet;
@ -111,7 +111,7 @@ bool GridBase::initWithSize(const Size& gridSize, Texture2D *pTexture, bool bFli
bool GridBase::initWithSize(const Size& gridSize)
{
Director *pDirector = Director::sharedDirector();
Director *pDirector = Director::getInstance();
Size s = pDirector->getWinSizeInPixels();
unsigned long POTWide = ccNextPOT((unsigned int)s.width);
@ -161,7 +161,7 @@ void GridBase::setActive(bool bActive)
_active = bActive;
if (! bActive)
{
Director *pDirector = Director::sharedDirector();
Director *pDirector = Director::getInstance();
ccDirectorProjection proj = pDirector->getProjection();
pDirector->setProjection(proj);
}
@ -178,7 +178,7 @@ void GridBase::setTextureFlipped(bool bFlipped)
void GridBase::set2DProjection()
{
Director *director = Director::sharedDirector();
Director *director = Director::getInstance();
Size size = director->getWinSizeInPixels();
@ -200,7 +200,7 @@ void GridBase::set2DProjection()
void GridBase::beforeDraw(void)
{
// save projection
Director *director = Director::sharedDirector();
Director *director = Director::getInstance();
_directorProjection = director->getProjection();
// 2d projection
@ -214,7 +214,7 @@ void GridBase::afterDraw(cocos2d::Node *pTarget)
_grabber->afterRender(_texture);
// restore projection
Director *director = Director::sharedDirector();
Director *director = Director::getInstance();
director->setProjection(_directorProjection);
if (pTarget->getCamera()->isDirty())
@ -232,8 +232,8 @@ void GridBase::afterDraw(cocos2d::Node *pTarget)
ccGLBindTexture2D(_texture->getName());
// restore projection for default FBO .fixed bug #543 #544
//TODO: Director::sharedDirector()->setProjection(Director::sharedDirector()->getProjection());
//TODO: Director::sharedDirector()->applyOrientation();
//TODO: Director::getInstance()->setProjection(Director::getInstance()->getProjection());
//TODO: Director::getInstance()->applyOrientation();
blit();
}

View File

@ -110,17 +110,17 @@ do { \
@since v0.99.4
*/
#define CC_DIRECTOR_END() \
#define CC_DIRECTOR_END() \
do { \
Director *__director = Director::sharedDirector(); \
__director->end(); \
Director *__director = Director::getInstance(); \
__director->end(); \
} while(0)
/** @def CC_CONTENT_SCALE_FACTOR
On Mac it returns 1;
On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1
*/
#define CC_CONTENT_SCALE_FACTOR() Director::sharedDirector()->getContentScaleFactor()
#define CC_CONTENT_SCALE_FACTOR() Director::getInstance()->getContentScaleFactor()
/****************************/
/** RETINA DISPLAY ENABLED **/
@ -194,8 +194,8 @@ It should work same as apples CFSwapInt32LittleToHost(..)
/**********************/
#if CC_ENABLE_PROFILERS
#define CC_PROFILER_DISPLAY_TIMERS() Profiler::sharedProfiler()->displayTimers()
#define CC_PROFILER_PURGE_ALL() Profiler::sharedProfiler()->releaseAllTimers()
#define CC_PROFILER_DISPLAY_TIMERS() Profiler::getInstance()->displayTimers()
#define CC_PROFILER_PURGE_ALL() Profiler::getInstance()->releaseAllTimers()
#define CC_PROFILER_START(__name__) ProfilingBeginTimingBlock(__name__)
#define CC_PROFILER_STOP(__name__) ProfilingEndTimingBlock(__name__)

View File

@ -57,7 +57,7 @@ LabelAtlas* LabelAtlas::create(const char *string, const char *charMapFile, unsi
bool LabelAtlas::initWithString(const char *string, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap)
{
Texture2D *texture = TextureCache::sharedTextureCache()->addImage(charMapFile);
Texture2D *texture = TextureCache::getInstance()->addImage(charMapFile);
return initWithString(string, texture, itemWidth, itemHeight, startCharMap);
}
@ -93,7 +93,7 @@ LabelAtlas* LabelAtlas::create(const char *string, const char *fntFile)
bool LabelAtlas::initWithString(const char *theString, const char *fntFile)
{
std::string pathStr = FileUtils::sharedFileUtils()->fullPathForFilename(fntFile);
std::string pathStr = FileUtils::getInstance()->fullPathForFilename(fntFile);
std::string relPathStr = pathStr.substr(0, pathStr.find_last_of("/"))+"/";
Dictionary *dict = Dictionary::createWithContentsOfFile(pathStr.c_str());

View File

@ -183,7 +183,7 @@ void CCBMFontConfiguration::purgeFontDefDictionary()
std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const char *controlFile)
{
std::string fullpath = FileUtils::sharedFileUtils()->fullPathForFilename(controlFile);
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(controlFile);
String *contents = String::createWithContentsOfFile(fullpath.c_str());
CCAssert(contents, "CCBMFontConfiguration::parseConfigFile | Open file error.");
@ -277,7 +277,7 @@ void CCBMFontConfiguration::parseImageFileName(std::string line, const char *fnt
index2 = line.find('"', index);
value = line.substr(index, index2-index);
_atlasName = FileUtils::sharedFileUtils()->fullPathFromRelativeFile(value.c_str(), fntFile);
_atlasName = FileUtils::getInstance()->fullPathFromRelativeFile(value.c_str(), fntFile);
}
void CCBMFontConfiguration::parseInfoArguments(std::string line)
@ -312,12 +312,12 @@ void CCBMFontConfiguration::parseCommonArguments(std::string line)
index = line.find("scaleW=") + strlen("scaleW=");
index2 = line.find(' ', index);
value = line.substr(index, index2-index);
CCAssert(atoi(value.c_str()) <= Configuration::sharedConfiguration()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported");
CCAssert(atoi(value.c_str()) <= Configuration::getInstance()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported");
// scaleH. sanity check
index = line.find("scaleH=") + strlen("scaleH=");
index2 = line.find(' ', index);
value = line.substr(index, index2-index);
CCAssert(atoi(value.c_str()) <= Configuration::sharedConfiguration()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported");
CCAssert(atoi(value.c_str()) <= Configuration::getInstance()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported");
// pages. sanity check
index = line.find("pages=") + strlen("pages=");
index2 = line.find(' ', index);
@ -488,7 +488,7 @@ bool LabelBMFont::initWithString(const char *theString, const char *fntFile, flo
_fntFile = fntFile;
texture = TextureCache::sharedTextureCache()->addImage(_configuration->getAtlasName());
texture = TextureCache::getInstance()->addImage(_configuration->getAtlasName());
}
else
{
@ -1223,7 +1223,7 @@ void LabelBMFont::setFntFile(const char* fntFile)
CC_SAFE_RELEASE(_configuration);
_configuration = newConf;
this->setTexture(TextureCache::sharedTextureCache()->addImage(_configuration->getAtlasName()));
this->setTexture(TextureCache::getInstance()->addImage(_configuration->getAtlasName()));
this->createFontChars();
}
}

View File

@ -132,7 +132,7 @@ bool LabelTTF::initWithString(const char *string, const char *fontName, float fo
if (Sprite::init())
{
// shader program
this->setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(SHADER_PROGRAM));
this->setShaderProgram(ShaderCache::getInstance()->programForKey(SHADER_PROGRAM));
_dimensions = CCSizeMake(dimensions.width, dimensions.height);
_alignment = hAlignment;
@ -153,7 +153,7 @@ bool LabelTTF::initWithStringAndTextDefinition(const char *string, FontDefinitio
if (Sprite::init())
{
// shader program
this->setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(SHADER_PROGRAM));
this->setShaderProgram(ShaderCache::getInstance()->programForKey(SHADER_PROGRAM));
// prepare everythin needed to render the label
_updateWithTextDefinition(textDefinition, false);

View File

@ -71,7 +71,7 @@ bool Layer::init()
do
{
Director * pDirector;
CC_BREAK_IF(!(pDirector = Director::sharedDirector()));
CC_BREAK_IF(!(pDirector = Director::getInstance()));
this->setContentSize(pDirector->getWinSize());
_touchEnabled = false;
_accelerometerEnabled = false;
@ -100,7 +100,7 @@ Layer *Layer::create()
void Layer::registerWithTouchDispatcher()
{
TouchDispatcher* pDispatcher = Director::sharedDirector()->getTouchDispatcher();
TouchDispatcher* pDispatcher = Director::getInstance()->getTouchDispatcher();
// Using LuaBindings
if (_scriptTouchHandlerEntry)
@ -193,7 +193,7 @@ void Layer::setTouchEnabled(bool enabled)
else
{
// have problems?
Director::sharedDirector()->getTouchDispatcher()->removeDelegate(this);
Director::getInstance()->getTouchDispatcher()->removeDelegate(this);
}
}
}
@ -251,7 +251,7 @@ void Layer::setAccelerometerEnabled(bool enabled)
if (_running)
{
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
if (enabled)
{
pDirector->getAccelerometer()->setDelegate(CC_CALLBACK_1(Layer::didAccelerate, this));
@ -270,7 +270,7 @@ void Layer::setAccelerometerInterval(double interval) {
{
if (_running)
{
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
pDirector->getAccelerometer()->setAccelerometerInterval(interval);
}
}
@ -316,7 +316,7 @@ void Layer::setKeyboardEnabled(bool enabled)
{
_keyboardEnabled = enabled;
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
if (enabled)
{
pDirector->getKeyboardDispatcher()->setKeyPressDelegate( CC_CALLBACK_1(Layer::keyPressed, this) );
@ -344,7 +344,7 @@ void Layer::setKeypadEnabled(bool enabled)
if (_running)
{
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
if (enabled)
{
pDirector->getKeypadDispatcher()->addDelegate(this);
@ -396,7 +396,7 @@ void Layer::keyMenuClicked(void)
/// Callbacks
void Layer::onEnter()
{
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
// register 'parent' nodes first
// since events are propagated in reverse order
if (_touchEnabled)
@ -422,7 +422,7 @@ void Layer::onEnter()
void Layer::onExit()
{
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
if( _touchEnabled )
{
pDirector->getTouchDispatcher()->removeDelegate(this);
@ -449,7 +449,7 @@ void Layer::onEnterTransitionDidFinish()
{
if (_accelerometerEnabled)
{
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
pDirector->getAccelerometer()->setDelegate(CC_CALLBACK_1(Layer::didAccelerate, this));
}
@ -758,7 +758,7 @@ LayerColor * LayerColor::create(const Color4B& color)
bool LayerColor::init()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
return initWithColor(Color4B(0,0,0,0), s.width, s.height);
}
@ -785,7 +785,7 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h)
updateColor();
setContentSize(CCSizeMake(w, h));
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionColor));
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionColor));
return true;
}
return false;
@ -793,7 +793,7 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h)
bool LayerColor::initWithColor(const Color4B& color)
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
this->initWithColor(color, s.width, s.height);
return true;
}

View File

@ -46,7 +46,7 @@ bool Scene::init()
do
{
Director * pDirector;
CC_BREAK_IF( ! (pDirector = Director::sharedDirector()) );
CC_BREAK_IF( ! (pDirector = Director::getInstance()) );
this->setContentSize(pDirector->getWinSize());
// success
bRet = true;

View File

@ -75,7 +75,7 @@ bool TransitionScene::initWithDuration(float t, Scene *scene)
// retain
_inScene = scene;
_inScene->retain();
_outScene = Director::sharedDirector()->getRunningScene();
_outScene = Director::getInstance()->getRunningScene();
if (_outScene == NULL)
{
_outScene = Scene::create();
@ -140,7 +140,7 @@ void TransitionScene::setNewScene(float dt)
this->unschedule(schedule_selector(TransitionScene::setNewScene));
// Before replacing, save the "send cleanup to scene"
Director *director = Director::sharedDirector();
Director *director = Director::getInstance();
_isSendCleanupToScene = director->isSendCleanupToScene();
director->replaceScene(_inScene);
@ -162,7 +162,7 @@ void TransitionScene::onEnter()
Scene::onEnter();
// disable events while transitions
Director::sharedDirector()->getTouchDispatcher()->setDispatchEvents(false);
Director::getInstance()->getTouchDispatcher()->setDispatchEvents(false);
// outScene should not receive the onEnter callback
// only the onExitTransitionDidStart
@ -177,7 +177,7 @@ void TransitionScene::onExit()
Scene::onExit();
// enable events while transitions
Director::sharedDirector()->getTouchDispatcher()->setDispatchEvents(true);
Director::getInstance()->getTouchDispatcher()->setDispatchEvents(true);
_outScene->onExit();
@ -306,7 +306,7 @@ TransitionJumpZoom* TransitionJumpZoom::create(float t, Scene* scene)
void TransitionJumpZoom::onEnter()
{
TransitionScene::onEnter();
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
_inScene->setScale(0.5f);
_inScene->setPosition(ccp(s.width, 0));
@ -389,7 +389,7 @@ ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action)
void TransitionMoveInL::initScenes()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
_inScene->setPosition(ccp(-s.width,0));
}
@ -417,7 +417,7 @@ TransitionMoveInR* TransitionMoveInR::create(float t, Scene* scene)
void TransitionMoveInR::initScenes()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( ccp(s.width,0) );
}
@ -445,7 +445,7 @@ TransitionMoveInT* TransitionMoveInT::create(float t, Scene* scene)
void TransitionMoveInT::initScenes()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( ccp(0,s.height) );
}
@ -473,7 +473,7 @@ TransitionMoveInB* TransitionMoveInB::create(float t, Scene* scene)
void TransitionMoveInB::initScenes()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( ccp(0,-s.height) );
}
@ -521,13 +521,13 @@ void TransitionSlideInL::sceneOrder()
void TransitionSlideInL:: initScenes()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( ccp(-(s.width-ADJUST_FACTOR),0) );
}
ActionInterval* TransitionSlideInL::action()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
return MoveBy::create(_duration, ccp(s.width-ADJUST_FACTOR,0));
}
@ -577,14 +577,14 @@ void TransitionSlideInR::sceneOrder()
void TransitionSlideInR::initScenes()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( ccp(s.width-ADJUST_FACTOR,0) );
}
ActionInterval* TransitionSlideInR:: action()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
return MoveBy::create(_duration, ccp(-(s.width-ADJUST_FACTOR),0));
}
@ -618,14 +618,14 @@ void TransitionSlideInT::sceneOrder()
void TransitionSlideInT::initScenes()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( ccp(0,s.height-ADJUST_FACTOR) );
}
ActionInterval* TransitionSlideInT::action()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
return MoveBy::create(_duration, ccp(0,-(s.height-ADJUST_FACTOR)));
}
@ -658,14 +658,14 @@ void TransitionSlideInB::sceneOrder()
void TransitionSlideInB:: initScenes()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( ccp(0,-(s.height-ADJUST_FACTOR)) );
}
ActionInterval* TransitionSlideInB:: action()
{
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
return MoveBy::create(_duration, ccp(0,s.height-ADJUST_FACTOR));
}
@ -1271,7 +1271,7 @@ void TransitionCrossFade::onEnter()
// create a transparent color layer
// in which we are going to add our rendertextures
Color4B color(0,0,0,0);
Size size = Director::sharedDirector()->getWinSize();
Size size = Director::getInstance()->getWinSize();
LayerColor* layer = LayerColor::create(color);
// create the first render texture for inScene
@ -1376,7 +1376,7 @@ void TransitionTurnOffTiles::sceneOrder()
void TransitionTurnOffTiles::onEnter()
{
TransitionScene::onEnter();
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
float aspect = s.width / s.height;
int x = (int)(12 * aspect);
int y = 12;
@ -1520,7 +1520,7 @@ void TransitionFadeTR::onEnter()
{
TransitionScene::onEnter();
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
float aspect = s.width / s.height;
int x = (int)(12 * aspect);
int y = 12;

View File

@ -70,7 +70,7 @@ void TransitionPageTurn::sceneOrder()
void TransitionPageTurn::onEnter()
{
TransitionScene::onEnter();
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
int x,y;
if (s.width > s.height)
{

View File

@ -42,7 +42,7 @@ to transition to the scene beneath it simulating a page turn.
This uses a 3DAction so it's strongly recommended that depth buffering
is turned on in Director using:
Director::sharedDirector()->setDepthBufferFormat(kDepthBuffer16);
Director::getInstance()->setDepthBufferFormat(kDepthBuffer16);
@since v0.8.2
*/

View File

@ -69,7 +69,7 @@ void TransitionProgress::onEnter()
// create a transparent color layer
// in which we are going to add our rendertextures
Size size = Director::sharedDirector()->getWinSize();
Size size = Director::getInstance()->getWinSize();
// create the second render texture for outScene
RenderTexture *texture = RenderTexture::create((int)size.width, (int)size.height);
@ -135,7 +135,7 @@ ProgressTimer* TransitionProgress::progressTimerNodeWithRenderTexture(RenderText
ProgressTimer* TransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(RenderTexture* texture)
{
Size size = Director::sharedDirector()->getWinSize();
Size size = Director::getInstance()->getWinSize();
ProgressTimer* pNode = ProgressTimer::create(texture->getSprite());
@ -179,7 +179,7 @@ TransitionProgressRadialCW* TransitionProgressRadialCW::create(float t, Scene* s
ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(RenderTexture* texture)
{
Size size = Director::sharedDirector()->getWinSize();
Size size = Director::getInstance()->getWinSize();
ProgressTimer* pNode = ProgressTimer::create(texture->getSprite());
@ -211,7 +211,7 @@ TransitionProgressHorizontal* TransitionProgressHorizontal::create(float t, Scen
ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture(RenderTexture* texture)
{
Size size = Director::sharedDirector()->getWinSize();
Size size = Director::getInstance()->getWinSize();
ProgressTimer* pNode = ProgressTimer::create(texture->getSprite());
@ -244,7 +244,7 @@ TransitionProgressVertical* TransitionProgressVertical::create(float t, Scene* s
ProgressTimer* TransitionProgressVertical::progressTimerNodeWithRenderTexture(RenderTexture* texture)
{
Size size = Director::sharedDirector()->getWinSize();
Size size = Director::getInstance()->getWinSize();
ProgressTimer* pNode = ProgressTimer::create(texture->getSprite());
@ -290,7 +290,7 @@ void TransitionProgressInOut::setupTransition()
ProgressTimer* TransitionProgressInOut::progressTimerNodeWithRenderTexture(RenderTexture* texture)
{
Size size = Director::sharedDirector()->getWinSize();
Size size = Director::getInstance()->getWinSize();
ProgressTimer* pNode = ProgressTimer::create(texture->getSprite());
@ -324,7 +324,7 @@ TransitionProgressOutIn* TransitionProgressOutIn::create(float t, Scene* scene)
ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(RenderTexture* texture)
{
Size size = Director::sharedDirector()->getWinSize();
Size size = Director::getInstance()->getWinSize();
ProgressTimer* pNode = ProgressTimer::create(texture->getSprite());

View File

@ -128,7 +128,7 @@ bool Menu::initWithArray(Array* pArrayOfItems)
_enabled = true;
// menu in the center of the screen
Size s = Director::sharedDirector()->getWinSize();
Size s = Director::getInstance()->getWinSize();
this->ignoreAnchorPointForPosition(true);
setAnchorPoint(ccp(0.5f, 0.5f));
@ -213,13 +213,13 @@ void Menu::removeChild(Node* child, bool cleanup)
void Menu::setHandlerPriority(int newPriority)
{
TouchDispatcher* pDispatcher = Director::sharedDirector()->getTouchDispatcher();
TouchDispatcher* pDispatcher = Director::getInstance()->getTouchDispatcher();
pDispatcher->setPriority(newPriority, this);
}
void Menu::registerWithTouchDispatcher()
{
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
pDirector->getTouchDispatcher()->addTargetedDelegate(this, this->getTouchPriority(), true);
}
@ -433,7 +433,7 @@ void Menu::alignItemsInColumnsWithArray(Array* rowsArray)
// check if too many rows/columns for available menu items
CCAssert(! columnsOccupied, "");
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
row = 0;
rowHeight = 0;
@ -555,7 +555,7 @@ void Menu::alignItemsInRowsWithArray(Array* columnArray)
// check if too many rows/columns for available menu items.
CCAssert(! rowsOccupied, "");
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
column = 0;
columnWidth = 0;

View File

@ -309,7 +309,7 @@ void ClippingNode::visit()
#else
// since glAlphaTest do not exists in OES, use a shader that writes
// pixel only if greater than an alpha threshold
GLProgram *program = ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTextureColorAlphaTest);
GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest);
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue);
// set our alphaThreshold
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);

View File

@ -95,7 +95,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
{
CCAssert(path != NULL, "Invalid filename");
Texture2D *texture = TextureCache::sharedTextureCache()->addImage(path);
Texture2D *texture = TextureCache::getInstance()->addImage(path);
return initWithFade(fade, minSeg, stroke, color, texture);
}
@ -128,7 +128,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
// shader program
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTextureColor));
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
setTexture(texture);
setColor(color);

View File

@ -85,7 +85,7 @@ bool ProgressTimer::initWithSprite(Sprite* sp)
setBarChangeRate(ccp(1,1));
setSprite(sp);
// shader program
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTextureColor));
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
return true;
}

View File

@ -62,12 +62,12 @@ RenderTexture::RenderTexture()
#if CC_ENABLE_CACHE_TEXTURE_DATA
// Listen this event to save render texture before come to background.
// Then it can be restored after coming to foreground on Android.
NotificationCenter::sharedNotificationCenter()->addObserver(this,
NotificationCenter::getInstance()->addObserver(this,
callfuncO_selector(RenderTexture::listenToBackground),
EVENT_COME_TO_BACKGROUND,
NULL);
NotificationCenter::sharedNotificationCenter()->addObserver(this,
NotificationCenter::getInstance()->addObserver(this,
callfuncO_selector(RenderTexture::listenToForeground),
EVNET_COME_TO_FOREGROUND, // this is misspelt
NULL);
@ -87,8 +87,8 @@ RenderTexture::~RenderTexture()
CC_SAFE_DELETE(_UITextureImage);
#if CC_ENABLE_CACHE_TEXTURE_DATA
NotificationCenter::sharedNotificationCenter()->removeObserver(this, EVENT_COME_TO_BACKGROUND);
NotificationCenter::sharedNotificationCenter()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
NotificationCenter::getInstance()->removeObserver(this, EVENT_COME_TO_BACKGROUND);
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
#endif
}
@ -264,7 +264,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF
unsigned int powW = 0;
unsigned int powH = 0;
if (Configuration::sharedConfiguration()->supportsNPOT())
if (Configuration::getInstance()->supportsNPOT())
{
powW = w;
powH = h;
@ -293,7 +293,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF
GLint oldRBO;
glGetIntegerv(GL_RENDERBUFFER_BINDING, &oldRBO);
if (Configuration::sharedConfiguration()->checkForGLExtension("GL_QCOM"))
if (Configuration::getInstance()->checkForGLExtension("GL_QCOM"))
{
_textureCopy = new Texture2D();
if (_textureCopy)
@ -366,7 +366,7 @@ void RenderTexture::begin()
kmGLMatrixMode(KM_GL_MODELVIEW);
kmGLPushMatrix();
Director *director = Director::sharedDirector();
Director *director = Director::getInstance();
director->setProjection(director->getProjection());
const Size& texSize = _texture->getContentSizeInPixels();
@ -390,7 +390,7 @@ void RenderTexture::begin()
/* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of RenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers.
*/
if (Configuration::sharedConfiguration()->checkForGLExtension("GL_QCOM"))
if (Configuration::getInstance()->checkForGLExtension("GL_QCOM"))
{
// -- bind a temporary texture so we can clear the render buffer without losing our texture
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _textureCopy->getName(), 0);
@ -461,7 +461,7 @@ void RenderTexture::beginWithClear(float r, float g, float b, float a, float dep
void RenderTexture::end()
{
Director *director = Director::sharedDirector();
Director *director = Director::getInstance();
glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO);
@ -628,7 +628,7 @@ bool RenderTexture::saveToFile(const char *fileName, tImageFormat format)
Image *pImage = newImage(true);
if (pImage)
{
std::string fullpath = FileUtils::sharedFileUtils()->getWritablePath() + fileName;
std::string fullpath = FileUtils::getInstance()->getWritablePath() + fileName;
bRet = pImage->saveToFile(fullpath.c_str(), true);
}

View File

@ -103,7 +103,7 @@ bool ParticleBatchNode::initWithTexture(Texture2D *tex, unsigned int capacity)
_blendFunc.src = CC_BLEND_SRC;
_blendFunc.dst = CC_BLEND_DST;
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTextureColor));
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
return true;
}
@ -113,7 +113,7 @@ bool ParticleBatchNode::initWithTexture(Texture2D *tex, unsigned int capacity)
*/
bool ParticleBatchNode::initWithFile(const char* fileImage, unsigned int capacity)
{
Texture2D *tex = TextureCache::sharedTextureCache()->addImage(fileImage);
Texture2D *tex = TextureCache::getInstance()->addImage(fileImage);
return initWithTexture(tex, capacity);
}

View File

@ -43,7 +43,7 @@ static Texture2D* getDefaultTexture()
{
bool bRet = false;
const char* key = "__firePngData";
pTexture = TextureCache::sharedTextureCache()->textureForKey(key);
pTexture = TextureCache::getInstance()->textureForKey(key);
CC_BREAK_IF(pTexture != NULL);
pImage = new Image();
@ -51,7 +51,7 @@ static Texture2D* getDefaultTexture()
bRet = pImage->initWithImageData((void*)__firePngData, sizeof(__firePngData), Image::kFmtPng);
CC_BREAK_IF(!bRet);
pTexture = TextureCache::sharedTextureCache()->addUIImage(pImage, key);
pTexture = TextureCache::getInstance()->addUIImage(pImage, key);
} while (0);
CC_SAFE_RELEASE(pImage);
@ -113,7 +113,7 @@ bool ParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
_angleVar = 10;
// emitter position
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(ccp(winSize.width/2, 60));
this->_posVar = ccp(40, 20);
@ -214,7 +214,7 @@ bool ParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
this->modeA.speedVar = 50;
// emitter position
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(ccp(winSize.width/2, winSize.height/2));
// angle
@ -323,7 +323,7 @@ bool ParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
_angleVar = 360;
// emitter position
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(ccp(winSize.width/2, winSize.height/2));
setPosVar(PointZero);
@ -430,7 +430,7 @@ bool ParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
_angleVar = 360;
// emitter position
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(ccp(winSize.width/2, winSize.height/2));
setPosVar(PointZero);
@ -539,7 +539,7 @@ bool ParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
_angleVar = 360;
// emitter position
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(ccp(winSize.width/2, winSize.height/2));
setPosVar(PointZero);
@ -647,7 +647,7 @@ bool ParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
_angleVar = 360;
// emitter position
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(ccp(winSize.width/2, winSize.height/2));
setPosVar(PointZero);
@ -756,7 +756,7 @@ bool ParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
_angleVar = 0;
// emitter position
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(ccp(winSize.width/2, winSize.height/2));
setPosVar(PointZero);
@ -864,7 +864,7 @@ bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
_angleVar = 360;
// emitter position
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(ccp(winSize.width/2, winSize.height/2));
setPosVar(PointZero);
@ -969,7 +969,7 @@ bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
_angleVar = 5;
// emitter position
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(ccp(winSize.width/2, 0));
setPosVar(ccp(20, 0));
@ -1074,7 +1074,7 @@ bool ParticleSnow::initWithTotalParticles(unsigned int numberOfParticles)
setTangentialAccelVar(1);
// emitter position
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(ccp(winSize.width/2, winSize.height + 10));
setPosVar(ccp(winSize.width/2, 0));
@ -1186,7 +1186,7 @@ bool ParticleRain::initWithTotalParticles(unsigned int numberOfParticles)
// emitter position
Size winSize = Director::sharedDirector()->getWinSize();
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(ccp(winSize.width/2, winSize.height));
setPosVar(ccp(winSize.width/2, 0));

View File

@ -168,7 +168,7 @@ bool ParticleSystem::init()
bool ParticleSystem::initWithFile(const char *plistFile)
{
bool bRet = false;
_plistFile = FileUtils::sharedFileUtils()->fullPathForFilename(plistFile);
_plistFile = FileUtils::getInstance()->fullPathForFilename(plistFile);
Dictionary *dict = Dictionary::createWithContentsOfFileThreadSafe(_plistFile.c_str());
CCAssert( dict != NULL, "Particles: file not found");
@ -340,11 +340,11 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
if (textureName.length() > 0)
{
// set not pop-up message box when load image failed
bool bNotify = FileUtils::sharedFileUtils()->isPopupNotify();
FileUtils::sharedFileUtils()->setPopupNotify(false);
tex = TextureCache::sharedTextureCache()->addImage(textureName.c_str());
bool bNotify = FileUtils::getInstance()->isPopupNotify();
FileUtils::getInstance()->setPopupNotify(false);
tex = TextureCache::getInstance()->addImage(textureName.c_str());
// reset the value of UIImage notify
FileUtils::sharedFileUtils()->setPopupNotify(bNotify);
FileUtils::getInstance()->setPopupNotify(bNotify);
}
if (tex)
@ -368,13 +368,13 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
CCAssert( deflated != NULL, "CCParticleSystem: error ungzipping textureImageData");
CC_BREAK_IF(!deflated);
// For android, we should retain it in VolatileTexture::addImage which invoked in TextureCache::sharedTextureCache()->addUIImage()
// For android, we should retain it in VolatileTexture::addImage which invoked in TextureCache::getInstance()->addUIImage()
image = new Image();
bool isOK = image->initWithImageData(deflated, deflatedLen);
CCAssert(isOK, "CCParticleSystem: error init image with Data");
CC_BREAK_IF(!isOK);
setTexture(TextureCache::sharedTextureCache()->addUIImage(image, textureName.c_str()));
setTexture(TextureCache::getInstance()->addUIImage(image, textureName.c_str()));
image->release();
}

View File

@ -63,11 +63,11 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles)
setupVBO();
#endif
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTextureColor));
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
// Need to listen the event only when not use batchnode, because it will use VBO
NotificationCenter::sharedNotificationCenter()->addObserver(this,
NotificationCenter::getInstance()->addObserver(this,
callfuncO_selector(ParticleSystemQuad::listenBackToForeground),
EVNET_COME_TO_FOREGROUND,
NULL);
@ -99,7 +99,7 @@ ParticleSystemQuad::~ParticleSystemQuad()
#endif
}
NotificationCenter::sharedNotificationCenter()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
}
// implementation ParticleSystemQuad

View File

@ -98,9 +98,9 @@ void EGLViewProtocol::setDesignResolutionSize(float width, float height, Resolut
_resolutionPolicy = resolutionPolicy;
// reset director's member variables to fit visible rect
Director::sharedDirector()->_winSizeInPoints = getDesignResolutionSize();
Director::sharedDirector()->createStatsLabel();
Director::sharedDirector()->setGLDefaultValues();
Director::getInstance()->_winSizeInPoints = getDesignResolutionSize();
Director::getInstance()->createStatsLabel();
Director::getInstance()->setGLDefaultValues();
}
const Size& EGLViewProtocol::getDesignResolutionSize() const

View File

@ -327,6 +327,7 @@ Array* FileUtils::createArrayWithContentsOfFile(const std::string& filename)
return tMaker.arrayWithContentsOfFile(fullPath.c_str());
}
/*
* forward statement
*/
@ -457,11 +458,23 @@ Array* FileUtils::createArrayWithContentsOfFile(const std::string& filename) {re
FileUtils* FileUtils::s_sharedFileUtils = NULL;
void FileUtils::purgeFileUtils()
// XXX: deprecated
FileUtils* FileUtils::sharedFileUtils()
{
return FileUtils::getInstance();
}
void FileUtils::destroyInstance()
{
CC_SAFE_DELETE(s_sharedFileUtils);
}
// XXX: deprecated
void FileUtils::purgeFileUtils()
{
FileUtils::destroyInstance();
}
FileUtils::FileUtils()
: _filenameLookupDict(NULL)
{
@ -472,6 +485,7 @@ FileUtils::~FileUtils()
CC_SAFE_RELEASE(_filenameLookupDict);
}
bool FileUtils::init()
{
_searchPathArray.push_back(_defaultResRootPath);

View File

@ -59,13 +59,19 @@ public:
/**
* Gets the instance of FileUtils.
*/
static FileUtils* sharedFileUtils();
static FileUtils* getInstance();
/**
* Destroys the instance of FileUtils.
*/
static void purgeFileUtils();
static void destroyInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static FileUtils* sharedFileUtils();
/** @deprecated Use destroyInstance() instead */
CC_DEPRECATED_ATTRIBUTE static void purgeFileUtils();
/**
* The destructor of FileUtils.
*/

View File

@ -116,8 +116,8 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
SDL_FreeSurface(iSurf);
#else
unsigned long nSize = 0;
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(strPath);
unsigned char* pBuffer = FileUtils::sharedFileUtils()->getFileData(fullPath.c_str(), "rb", &nSize);
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(strPath);
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(fullPath.c_str(), "rb", &nSize);
if (pBuffer != NULL && nSize > 0)
{
bRet = initWithImageData(pBuffer, nSize, eImgFmt);
@ -133,10 +133,10 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat image
bool bRet = false;
unsigned long nSize = 0;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
FileUtilsAndroid *fileUitls = (FileUtilsAndroid*)FileUtils::sharedFileUtils();
FileUtilsAndroid *fileUitls = (FileUtilsAndroid*)FileUtils::getInstance();
unsigned char *pBuffer = fileUitls->getFileDataForAsync(fullpath, "rb", &nSize);
#else
unsigned char *pBuffer = FileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize);
unsigned char *pBuffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &nSize);
#endif
if (pBuffer != NULL && nSize > 0)
{

View File

@ -116,7 +116,7 @@ bool SAXParser::parse(const char *pszFile)
{
bool bRet = false;
unsigned long size = 0;
char* pBuffer = (char*)FileUtils::sharedFileUtils()->getFileData(pszFile, "rt", &size);
char* pBuffer = (char*)FileUtils::getInstance()->getFileData(pszFile, "rt", &size);
if (pBuffer != NULL && size > 0)
{
bRet = parse(pBuffer, size);

View File

@ -79,12 +79,18 @@ void EGLView::swapBuffers()
{
}
EGLView* EGLView::sharedOpenGLView()
EGLView* EGLView::getInstance()
{
static EGLView instance;
return &instance;
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
void EGLView::setIMEKeyboardState(bool bOpen)
{
setKeyboardStateJNI((int)bOpen);

View File

@ -47,7 +47,10 @@ public:
/**
@brief get the shared main open gl window
*/
static EGLView* sharedOpenGLView();
static EGLView* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
};
NS_CC_END

View File

@ -54,7 +54,7 @@ extern "C" {
NS_CC_BEGIN
FileUtils* FileUtils::sharedFileUtils()
FileUtils* FileUtils::getInstance()
{
if (s_sharedFileUtils == NULL)
{

View File

@ -91,7 +91,7 @@ public:
// Do a full lookup for the font path using FileUtils in case the given font name is a relative path to a font file asset,
// or the path has been mapped to a different location in the app package:
std::string fullPathOrFontName = FileUtils::sharedFileUtils()->fullPathForFilename(pFontName);
std::string fullPathOrFontName = FileUtils::getInstance()->fullPathForFilename(pFontName);
// If the path name returned includes the 'assets' dir then that needs to be removed, because the android.content.Context
// requires this portion of the path to be omitted for assets inside the app package.

View File

@ -9,7 +9,7 @@ using namespace cocos2d;
extern "C" {
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged(JNIEnv* env, jobject thiz, jfloat x, jfloat y, jfloat z, jlong timeStamp) {
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
pDirector->getAccelerometer()->update(x, y, z, timeStamp);
}
}

View File

@ -11,17 +11,17 @@ using namespace cocos2d;
extern "C" {
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender(JNIEnv* env) {
cocos2d::Director::sharedDirector()->mainLoop();
cocos2d::Director::getInstance()->mainLoop();
}
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() {
Application::sharedApplication()->applicationDidEnterBackground();
NotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_BACKGROUND, NULL);
NotificationCenter::getInstance()->postNotification(EVENT_COME_TO_BACKGROUND, NULL);
}
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() {
if (Director::sharedDirector()->getOpenGLView()) {
if (Director::getInstance()->getOpenGLView()) {
Application::sharedApplication()->applicationWillEnterForeground();
}
}

View File

@ -35,11 +35,11 @@ using namespace cocos2d;
extern "C" {
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) {
cocos2d::Director::sharedDirector()->getOpenGLView()->handleTouchesBegin(1, &id, &x, &y);
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, &id, &x, &y);
}
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) {
cocos2d::Director::sharedDirector()->getOpenGLView()->handleTouchesEnd(1, &id, &x, &y);
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, &id, &x, &y);
}
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesMove(JNIEnv * env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) {
@ -52,7 +52,7 @@ extern "C" {
env->GetFloatArrayRegion(xs, 0, size, x);
env->GetFloatArrayRegion(ys, 0, size, y);
cocos2d::Director::sharedDirector()->getOpenGLView()->handleTouchesMove(size, id, x, y);
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(size, id, x, y);
}
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesCancel(JNIEnv * env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) {
@ -65,14 +65,14 @@ extern "C" {
env->GetFloatArrayRegion(xs, 0, size, x);
env->GetFloatArrayRegion(ys, 0, size, y);
cocos2d::Director::sharedDirector()->getOpenGLView()->handleTouchesCancel(size, id, x, y);
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(size, id, x, y);
}
#define KEYCODE_BACK 0x04
#define KEYCODE_MENU 0x52
JNIEXPORT jboolean JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyDown(JNIEnv * env, jobject thiz, jint keyCode) {
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
switch (keyCode) {
case KEYCODE_BACK:
if (pDirector->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked))

View File

@ -50,7 +50,7 @@ int Application::run()
while (1) // or device wants to quit
{
EGLView::sharedOpenGLView()->handleEvents();
EGLView::getInstance()->handleEvents();
clock_gettime(CLOCK_REALTIME, &time_struct);
current_time = time2millis(&time_struct);
@ -58,7 +58,7 @@ int Application::run()
if ((current_time - update_time) > _animationInterval)
{
update_time = current_time;
Director::sharedDirector()->mainLoop();
Director::getInstance()->mainLoop();
}
else
{
@ -82,7 +82,7 @@ void Application::setResourceRootPath(const std::string& rootResDir)
{
_resourceRootPath += '/';
}
FileUtils* pFileUtils = FileUtils::sharedFileUtils();
FileUtils* pFileUtils = FileUtils::getInstance();
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin(), _resourceRootPath);
pFileUtils->setSearchPaths(searchPaths);

View File

@ -45,13 +45,13 @@ public:
/**
* Sets the Resource root path.
* @deprecated Please use FileUtils::sharedFileUtils()->setSearchPaths() instead.
* @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
/**
* Gets the Resource root path.
* @deprecated Please use FileUtils::sharedFileUtils()->getSearchPaths() instead.
* @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);

View File

@ -11,7 +11,7 @@ int Device::getDPI()
static int dpi = -1;
if (dpi == -1)
{
screen_display_t screen_disp = EGLView::sharedOpenGLView()->getScreenDisplay();
screen_display_t screen_disp = EGLView::getInstance()->getScreenDisplay();
#ifdef BLACKBERRY10
// Dev Alpha: 1280x768, 4.2", 356DPI, 0.6f scale

View File

@ -207,7 +207,7 @@ void EGLView::swapBuffers()
eglSwapBuffers(_eglDisplay, _eglSurface);
}
EGLView* EGLView::sharedOpenGLView()
EGLView* EGLView::getInstance()
{
if (!s_pInstance)
{
@ -218,6 +218,12 @@ EGLView* EGLView::sharedOpenGLView()
return s_pInstance;
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
void EGLView::showKeyboard()
{
int height;
@ -607,7 +613,7 @@ bool EGLView::handleEvents()
switch (bps_event_get_code(event))
{
case NAVIGATOR_SWIPE_DOWN:
Director::sharedDirector()->getKeypadDispatcher()->dispatchKeypadMSG(kTypeMenuClicked);
Director::getInstance()->getKeypadDispatcher()->dispatchKeypadMSG(kTypeMenuClicked);
break;
case NAVIGATOR_EXIT:
@ -790,7 +796,7 @@ bool EGLView::handleEvents()
current_time = time2millis(&time_struct);
sensor_event_get_xyz(event, &x, &y, &z);
Director::sharedDirector()->getAccelerometer()->update(current_time, -x, -y, z);
Director::getInstance()->getAccelerometer()->update(current_time, -x, -y, z);
}
}
}

View File

@ -61,7 +61,10 @@ public:
/**
@brief get the shared main open gl window
*/
static EGLView* sharedOpenGLView();
static EGLView* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
bool handleEvents();
screen_display_t getScreenDisplay() const;

View File

@ -9,7 +9,7 @@ using namespace std;
NS_CC_BEGIN
FileUtils* FileUtils::sharedFileUtils()
FileUtils* FileUtils::getInstance()
{
if (s_sharedFileUtils == NULL)
{

View File

@ -413,7 +413,7 @@ bool Image::initWithString(
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
fullFontName = FileUtils::sharedFileUtils()->fullPathForFilename(pFontName);
fullFontName = FileUtils::getInstance()->fullPathForFilename(pFontName);
}
//CCLog("-----pText=%s and Font File is %s nWidth= %d,nHeight=%d",pText,fullFontName.c_str(),nWidth,nHeight);

View File

@ -37,8 +37,8 @@ Application::~Application()
extern "C" void mainLoopIter(void)
{
EGLView::sharedOpenGLView()->handleEvents();
Director::sharedDirector()->mainLoop();
EGLView::getInstance()->handleEvents();
Director::getInstance()->mainLoop();
}
int Application::run()
@ -74,7 +74,7 @@ void Application::setResourceRootPath(const std::string& rootResDir)
{
_resourceRootPath += '/';
}
FileUtils* pFileUtils = FileUtils::sharedFileUtils();
FileUtils* pFileUtils = FileUtils::getInstance();
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin(), _resourceRootPath);
pFileUtils->setSearchPaths(searchPaths);

View File

@ -45,13 +45,13 @@ public:
/**
* Sets the Resource root path.
* @deprecated Please use FileUtils::sharedFileUtils()->setSearchPaths() instead.
* @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
/**
* Gets the Resource root path.
* @deprecated Please use FileUtils::sharedFileUtils()->getSearchPaths() instead.
* @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);

View File

@ -77,7 +77,7 @@ extern "C" void mouseCB(int button, int state, int x, int y)
{
float fx = x;
float fy = y;
EGLView* pEGLView = EGLView::sharedOpenGLView();
EGLView* pEGLView = EGLView::getInstance();
int id = 0;
if(button != glutLeftButton) return;
@ -98,7 +98,7 @@ extern "C" void motionCB(int x, int y)
{
float fx = x;
float fy = y;
EGLView* pEGLView = EGLView::sharedOpenGLView();
EGLView* pEGLView = EGLView::getInstance();
int id = 0;
if(buttonDepressed)
@ -201,7 +201,7 @@ void EGLView::swapBuffers()
eglSwapBuffers(_eglDisplay, _eglSurface);
}
EGLView* EGLView::sharedOpenGLView()
EGLView* EGLView::getInstance()
{
if (!s_pInstance)
{
@ -212,6 +212,12 @@ EGLView* EGLView::sharedOpenGLView()
return s_pInstance;
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
void EGLView::showKeyboard()
{
}

View File

@ -52,8 +52,11 @@ public:
/**
@brief get the shared main open gl window
*/
static EGLView* sharedOpenGLView();
static EGLView* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
bool handleEvents();
private:

View File

@ -9,7 +9,7 @@ using namespace std;
NS_CC_BEGIN
FileUtils* FileUtils::sharedFileUtils()
FileUtils* FileUtils::getInstance()
{
if (s_sharedFileUtils == NULL)
{

View File

@ -162,7 +162,7 @@ void TextureCacheEmscripten::addImageAsync(const char *path, Object *target, SEL
Texture2D *texture = NULL;
// optimization
std::string pathKey = FileUtils::sharedFileUtils()->fullPathForFilename(path);
std::string pathKey = FileUtils::getInstance()->fullPathForFilename(path);
texture = (Texture2D*)_textures->objectForKey(pathKey.c_str());
std::string fullpath = pathKey;

View File

@ -91,7 +91,7 @@ static id s_sharedDirectorCaller;
-(void) doCaller: (id) sender
{
cocos2d::Director::sharedDirector()->mainLoop();
cocos2d::Director::getInstance()->mainLoop();
}
@end

View File

@ -46,8 +46,12 @@ public:
virtual void swapBuffers();
virtual void setIMEKeyboardState(bool bOpen);
static EGLView* sharedOpenGLView();
/** returns the singleton */
static EGLView* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
};

View File

@ -82,11 +82,17 @@ void EGLView::setIMEKeyboardState(bool bOpen)
}
}
EGLView* EGLView::sharedOpenGLView()
EGLView* EGLView::getInstance()
{
static EGLView instance;
return &instance;
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
NS_CC_END

View File

@ -208,7 +208,7 @@ static void addObjectToNSDict(const char * key, Object* object, NSMutableDiction
}
}
FileUtils* FileUtils::sharedFileUtils()
FileUtils* FileUtils::getInstance()
{
if (s_sharedFileUtils == NULL)
{
@ -303,7 +303,7 @@ bool FileUtilsIOS::isAbsolutePath(const std::string& strPath)
Dictionary* FileUtilsIOS::createDictionaryWithContentsOfFile(const std::string& filename)
{
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(filename.c_str());
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str());
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()];
NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath];
@ -348,7 +348,7 @@ Array* FileUtilsIOS::createArrayWithContentsOfFile(const std::string& filename)
// pPath = [pPath stringByDeletingPathExtension];
// pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension];
// fixing cannot read data using Array::createWithContentsOfFile
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(filename.c_str());
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str());
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()];
NSArray* pArray = [NSArray arrayWithContentsOfFile:pPath];

View File

@ -416,8 +416,8 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
{
bool bRet = false;
unsigned long nSize = 0;
unsigned char* pBuffer = FileUtils::sharedFileUtils()->getFileData(
FileUtils::sharedFileUtils()->fullPathForFilename(strPath).c_str(),
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(
FileUtils::getInstance()->fullPathForFilename(strPath).c_str(),
"rb",
&nSize);
@ -436,7 +436,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat image
*/
bool bRet = false;
unsigned long nSize = 0;
unsigned char* pBuffer = FileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize);
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &nSize);
if (pBuffer != NULL && nSize > 0)
{
bRet = initWithImageData(pBuffer, nSize, imageType);

View File

@ -263,11 +263,11 @@ static CCEAGLView *view = 0;
cocos2d::Size size;
size.width = size_.width;
size.height = size_.height;
//cocos2d::Director::sharedDirector()->reshapeProjection(size);
//cocos2d::Director::getInstance()->reshapeProjection(size);
// Avoid flicker. Issue #350
//[director performSelectorOnMainThread:@selector(drawScene) withObject:nil waitUntilDone:YES];
cocos2d::Director::sharedDirector()->drawScene();
cocos2d::Director::getInstance()->drawScene();
}
- (void) swapBuffers
@ -410,7 +410,7 @@ static CCEAGLView *view = 0;
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
++i;
}
cocos2d::EGLView::sharedOpenGLView()->handleTouchesBegin(i, ids, xs, ys);
cocos2d::EGLView::getInstance()->handleTouchesBegin(i, ids, xs, ys);
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
@ -430,7 +430,7 @@ static CCEAGLView *view = 0;
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
++i;
}
cocos2d::EGLView::sharedOpenGLView()->handleTouchesMove(i, ids, xs, ys);
cocos2d::EGLView::getInstance()->handleTouchesMove(i, ids, xs, ys);
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
@ -451,7 +451,7 @@ static CCEAGLView *view = 0;
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
++i;
}
cocos2d::EGLView::sharedOpenGLView()->handleTouchesEnd(i, ids, xs, ys);
cocos2d::EGLView::getInstance()->handleTouchesEnd(i, ids, xs, ys);
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
@ -472,7 +472,7 @@ static CCEAGLView *view = 0;
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
++i;
}
cocos2d::EGLView::sharedOpenGLView()->handleTouchesCancel(i, ids, xs, ys);
cocos2d::EGLView::getInstance()->handleTouchesCancel(i, ids, xs, ys);
}
#pragma mark -
@ -797,8 +797,8 @@ static CCEAGLView *view = 0;
break;
}
float scaleX = cocos2d::EGLView::sharedOpenGLView()->getScaleX();
float scaleY = cocos2d::EGLView::sharedOpenGLView()->getScaleY();
float scaleX = cocos2d::EGLView::getInstance()->getScaleX();
float scaleY = cocos2d::EGLView::getInstance()->getScaleY();
if (self.contentScaleFactor == 2.0f)
@ -809,7 +809,7 @@ static CCEAGLView *view = 0;
end = CGRectApplyAffineTransform(end, CGAffineTransformScale(CGAffineTransformIdentity, 2.0f, 2.0f));
}
float offestY = cocos2d::EGLView::sharedOpenGLView()->getViewPortRect().origin.y;
float offestY = cocos2d::EGLView::getInstance()->getViewPortRect().origin.y;
CCLOG("offestY = %f", offestY);
if (offestY < 0.0f)
{
@ -868,11 +868,11 @@ static CCEAGLView *view = 0;
[UIView setAnimationDuration:duration];
[UIView setAnimationBeginsFromCurrentState:YES];
//NSLog(@"[animation] dis = %f, scale = %f \n", dis, cocos2d::EGLView::sharedOpenGLView()->getScaleY());
//NSLog(@"[animation] dis = %f, scale = %f \n", dis, cocos2d::EGLView::getInstance()->getScaleY());
if (dis < 0.0f) dis = 0.0f;
dis *= cocos2d::EGLView::sharedOpenGLView()->getScaleY();
dis *= cocos2d::EGLView::getInstance()->getScaleY();
if (self.contentScaleFactor == 2.0f)
{

View File

@ -50,7 +50,7 @@ int Application::run()
for (;;) {
long iLastTime = getCurrentMillSecond();
Director::sharedDirector()->mainLoop();
Director::getInstance()->mainLoop();
long iCurTime = getCurrentMillSecond();
if (iCurTime-iLastTime<_animationInterval){
usleep((_animationInterval - iCurTime+iLastTime)*1000);
@ -73,7 +73,7 @@ void Application::setResourceRootPath(const std::string& rootResDir)
{
_resourceRootPath += '/';
}
FileUtils* pFileUtils = FileUtils::sharedFileUtils();
FileUtils* pFileUtils = FileUtils::getInstance();
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin(), _resourceRootPath);
pFileUtils->setSearchPaths(searchPaths);

View File

@ -43,13 +43,13 @@ public:
/**
* Sets the Resource root path.
* @deprecated Please use FileUtils::sharedFileUtils()->setSearchPaths() instead.
* @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
/**
* Gets the Resource root path.
* @deprecated Please use FileUtils::sharedFileUtils()->getSearchPaths() instead.
* @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);

View File

@ -111,7 +111,7 @@ void charEventHandle(int iCharID,int iCharState) {
void mouseButtonEventHandle(int iMouseID,int iMouseState) {
if (iMouseID == GLFW_MOUSE_BUTTON_LEFT) {
EGLView* pEGLView = EGLView::sharedOpenGLView();
EGLView* pEGLView = EGLView::getInstance();
//get current mouse pos
int x,y;
glfwGetMousePos(&x, &y);
@ -140,7 +140,7 @@ void mousePosEventHandle(int iPosX,int iPosY) {
//to test move
if (iButtonState == GLFW_PRESS) {
EGLView* pEGLView = EGLView::sharedOpenGLView();
EGLView* pEGLView = EGLView::getInstance();
int id = 0;
float x = (float)iPosX;
float y = (float)iPosY;
@ -151,13 +151,13 @@ void mousePosEventHandle(int iPosX,int iPosY) {
}
int closeEventHandle() {
Director::sharedDirector()->end();
Director::getInstance()->end();
return GL_TRUE;
}
void GLFWCALL keyboardEventHandle(int keyCode, int action)
{
KeyboardDispatcher *kbDisp = Director::sharedDirector()->getKeyboardDispatcher();
KeyboardDispatcher *kbDisp = Director::getInstance()->getKeyboardDispatcher();
switch (action)
{
@ -265,7 +265,7 @@ void EGLView::setFrameZoomFactor(float fZoomFactor)
{
_frameZoomFactor = fZoomFactor;
glfwSetWindowSize(_screenSize.width * fZoomFactor, _screenSize.height * fZoomFactor);
Director::sharedDirector()->setProjection(Director::sharedDirector()->getProjection());
Director::getInstance()->setProjection(Director::getInstance()->getProjection());
}
float EGLView::getFrameZoomFactor()
@ -359,7 +359,7 @@ void EGLView::destroyGL()
*/
}
EGLView* EGLView::sharedOpenGLView()
EGLView* EGLView::getInstance()
{
static EGLView* s_pEglView = NULL;
if (s_pEglView == NULL)
@ -369,4 +369,10 @@ EGLView* EGLView::sharedOpenGLView()
return s_pEglView;
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
NS_CC_END

View File

@ -48,7 +48,11 @@ public:
/**
@brief get the shared main open gl window
*/
static EGLView* sharedOpenGLView();
static EGLView* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
private:
bool initGL();
void destroyGL();

View File

@ -18,7 +18,7 @@ using namespace std;
NS_CC_BEGIN
FileUtils* FileUtils::sharedFileUtils()
FileUtils* FileUtils::getInstance()
{
if (s_sharedFileUtils == NULL)
{

View File

@ -278,7 +278,7 @@ public:
std::string lowerCasePath = fontPath;
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
fontPath = cocos2d::FileUtils::sharedFileUtils()->fullPathForFilename(fontPath.c_str());
fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath.c_str());
FILE *f = fopen(fontPath.c_str(), "r");
if ( f ) {
@ -439,7 +439,7 @@ bool Image::initWithString(
BitmapDC &dc = sharedBitmapDC();
//const char* pFullFontName = FileUtils::sharedFileUtils()->fullPathFromRelativePath(pFontName);
//const char* pFullFontName = FileUtils::getInstance()->fullPathFromRelativePath(pFontName);
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFontName, nSize));

View File

@ -71,13 +71,13 @@ public:
/**
* Sets the Resource root path.
* @deprecated Please use FileUtils::sharedFileUtils()->setSearchPaths() instead.
* @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
/**
* Gets the Resource root path.
* @deprecated Please use FileUtils::sharedFileUtils()->getSearchPaths() instead.
* @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);

View File

@ -143,7 +143,7 @@ void Application::setResourceRootPath(const std::string& rootResDir)
{
_resourceRootPath += '/';
}
FileUtils* pFileUtils = FileUtils::sharedFileUtils();
FileUtils* pFileUtils = FileUtils::getInstance();
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin(), _resourceRootPath);
pFileUtils->setSearchPaths(searchPaths);

View File

@ -79,7 +79,7 @@ static id s_sharedDirectorCaller;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
cocos2d::Director::sharedDirector()->drawScene();
cocos2d::Director::getInstance()->drawScene();
cocos2d::PoolManager::sharedPoolManager()->pop();
[[CCEventDispatcher sharedDispatcher] dispatchQueuedEvents];
@ -101,7 +101,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
// CVReturn result = [(DirectorCaller*)displayLinkContext getFrameForTime:outputTime];
// return result;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
cocos2d::Director::sharedDirector()->mainLoop();
cocos2d::Director::getInstance()->mainLoop();
[pool release];
return kCVReturnSuccess;
@ -119,7 +119,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
[openGLView lockOpenGLContext];
// run the main cocos2d loop
cocos2d::Director::sharedDirector()->mainLoop();
cocos2d::Director::getInstance()->mainLoop();
// flush buffer (this line is very important!)
[[openGLView openGLContext] flushBuffer];
@ -162,7 +162,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
/*
// CVDisplayLink
//cocos2d::Director::sharedDirector()->gettimeofday();
//cocos2d::Director::getInstance()->gettimeofday();
// Create a display link capable of being used with all active displays
CVDisplayLinkCreateWithActiveCGDisplays(&displayLink);
@ -207,7 +207,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
-(void) doCaller: (id) sender
{
cocos2d::Director::sharedDirector()->mainLoop();
cocos2d::Director::getInstance()->mainLoop();
}
@end

View File

@ -37,8 +37,11 @@ class Size;
class CC_DLL EGLView : public EGLViewProtocol
{
public:
static EGLView* sharedOpenGLView(void);
static EGLView* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
virtual ~EGLView(void);
virtual bool isOpenGLReady(void);

View File

@ -32,7 +32,7 @@ NS_CC_BEGIN
EGLView* EGLView::s_sharedView = NULL;
EGLView* EGLView::sharedOpenGLView(void)
EGLView* EGLView::getInstance(void)
{
if (!s_sharedView)
{
@ -41,6 +41,12 @@ EGLView* EGLView::sharedOpenGLView(void)
return s_sharedView;
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
EGLView::EGLView(void)
{
}

View File

@ -505,7 +505,7 @@ static int eventQueueCount;
{
if( dispatchEvents_ ) {
tListEntry *entry, *tmp;
cocos2d::Director::sharedDirector()->getKeyboardDispatcher()->dispatchKeyboardEvent(event.keyCode, true);
cocos2d::Director::getInstance()->getKeyboardDispatcher()->dispatchKeyboardEvent(event.keyCode, true);
DL_FOREACH_SAFE( keyboardDelegates_, entry, tmp ) {
if ( entry->flags & kImplementsKeyDown ) {
@ -521,7 +521,7 @@ static int eventQueueCount;
{
if( dispatchEvents_ ) {
tListEntry *entry, *tmp;
cocos2d::Director::sharedDirector()->getKeyboardDispatcher()->dispatchKeyboardEvent(event.keyCode, false);
cocos2d::Director::getInstance()->getKeyboardDispatcher()->dispatchKeyboardEvent(event.keyCode, false);
DL_FOREACH_SAFE( keyboardDelegates_, entry, tmp ) {
if ( entry->flags & kImplementsKeyUp ) {

View File

@ -205,7 +205,7 @@ static void addObjectToNSDict(const char * key, Object* object, NSMutableDiction
}
}
FileUtils* FileUtils::sharedFileUtils()
FileUtils* FileUtils::getInstance()
{
if (s_sharedFileUtils == NULL)
{
@ -295,7 +295,7 @@ bool FileUtilsMac::isAbsolutePath(const std::string& strPath)
Dictionary* FileUtilsMac::createDictionaryWithContentsOfFile(const std::string& filename)
{
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(filename.c_str());
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str());
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()];
NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath];
@ -331,7 +331,7 @@ Array* FileUtilsMac::createArrayWithContentsOfFile(const std::string& filename)
// pPath = [pPath stringByDeletingPathExtension];
// pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension];
// fixing cannot read data using Array::createWithContentsOfFile
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(filename.c_str());
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str());
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()];
NSArray* pArray = [NSArray arrayWithContentsOfFile:pPath];

View File

@ -238,7 +238,7 @@ static bool _initWithImage(CGImageRef CGImage, tImageInfo *pImageinfo, double sc
}
//if (cocos2d::Image::getIsScaleEnabled())
if( cocos2d::Director::sharedDirector()->getContentScaleFactor() > 1.0f )
if( cocos2d::Director::getInstance()->getContentScaleFactor() > 1.0f )
{
POTWide = CGImageGetWidth(CGImage) * scaleX;
POTHigh = CGImageGetHeight(CGImage) * scaleY;
@ -565,7 +565,7 @@ Image::~Image()
bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/)
{
std::string strTemp = FileUtils::sharedFileUtils()->fullPathForFilename(strPath);
std::string strTemp = FileUtils::getInstance()->fullPathForFilename(strPath);
if (_enabledScale)
{
if (!isFileExists(strTemp.c_str()))
@ -577,7 +577,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
{
strTemp.insert(t, "@2x");
}
/* Size size = Director::sharedDirector()->getWinSize();
/* Size size = Director::getInstance()->getWinSize();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
_scaleX = size.width/800.0f;
_scaleY = size.height/480.0f;
@ -600,7 +600,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
// return initWithImageData(tempData.getBuffer(), tempData.getSize(), eImgFmt);
unsigned long fileSize = 0;
unsigned char* pFileData = FileUtils::sharedFileUtils()->getFileData(strTemp.c_str(), "rb", &fileSize);
unsigned char* pFileData = FileUtils::getInstance()->getFileData(strTemp.c_str(), "rb", &fileSize);
bool ret = initWithImageData(pFileData, fileSize, eImgFmt);
delete []pFileData;
return ret;
@ -613,7 +613,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat image
*/
bool bRet = false;
unsigned long nSize = 0;
unsigned char* pBuffer = FileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize);
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &nSize);
if (pBuffer != NULL && nSize > 0)
{
bRet = initWithImageData(pBuffer, nSize, imageType);

View File

@ -85,7 +85,7 @@ static CCEAGLView *view;
eventDelegate_ = [CCEventDispatcher sharedDispatcher];
}
cocos2d::EGLView::sharedOpenGLView()->setFrameSize(frameRect.size.width, frameRect.size.height);
cocos2d::EGLView::getInstance()->setFrameSize(frameRect.size.width, frameRect.size.height);
frameZoomFactor_ = 1.0f;
@ -97,7 +97,7 @@ static CCEAGLView *view;
// event delegate
eventDelegate_ = [CCEventDispatcher sharedDispatcher];
cocos2d::EGLView::sharedOpenGLView()->setFrameSize(frameRect.size.width, frameRect.size.height);
cocos2d::EGLView::getInstance()->setFrameSize(frameRect.size.width, frameRect.size.height);
frameZoomFactor_ = 1.0f;
@ -170,7 +170,7 @@ static CCEAGLView *view;
// NSRect rect = [self bounds];
cocos2d::Director *director = cocos2d::Director::sharedDirector();
cocos2d::Director *director = cocos2d::Director::getInstance();
// CGSize size = NSSizeToCGSize(rect.size);
// cocos2d::Size ccsize = cocos2d::CCSizeMake(size.width, size.height);
//director->reshapeProjection(ccsize);
@ -294,7 +294,7 @@ static CCEAGLView *view;
// is this necessary?
// re-configure glView
//cocos2d::Director *director = cocos2d::Director::sharedDirector();
//cocos2d::Director *director = cocos2d::Director::getInstance();
//director->setOpenGLView(openGLview); //[self setView:openGLview];
//[openGLview release]; // Retain -1
@ -335,7 +335,7 @@ static CCEAGLView *view;
xs[0] = x / frameZoomFactor_;
ys[0] = y / frameZoomFactor_;
cocos2d::Director::sharedDirector()->getOpenGLView()->handleTouchesBegin(1, ids, xs, ys);
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, ids, xs, ys);
}
- (void)mouseMoved:(NSEvent *)theEvent
@ -359,7 +359,7 @@ static CCEAGLView *view;
xs[0] = x / frameZoomFactor_;
ys[0] = y / frameZoomFactor_;
cocos2d::Director::sharedDirector()->getOpenGLView()->handleTouchesMove(1, ids, xs, ys);
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(1, ids, xs, ys);
}
- (void)mouseUp:(NSEvent *)theEvent
@ -378,7 +378,7 @@ static CCEAGLView *view;
xs[0] = x / frameZoomFactor_;
ys[0] = y / frameZoomFactor_;
cocos2d::Director::sharedDirector()->getOpenGLView()->handleTouchesEnd(1, ids, xs, ys);
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, ids, xs, ys);
}
- (void)rightMouseDown:(NSEvent *)theEvent {

View File

@ -81,7 +81,7 @@ int Application::Run()
quitRequested = s3eDeviceCheckQuitRequest();
if( quitRequested) {
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
// if opengl view has been released, delete the director.
if (pDirector->getOpenGLView() == NULL)
{
@ -98,7 +98,7 @@ int Application::Run()
break;
}
Director::sharedDirector()->mainLoop();
Director::getInstance()->mainLoop();
while ((s3eTimerGetMs() - updateTime) < _animationInterval) {
int32 yield = (int32) (_animationInterval - (s3eTimerGetMs() - updateTime));
@ -122,7 +122,7 @@ void Application::ccAccelerationUpdate()
{
// Accelerometer doesn't work on Marmalade X86 MacOS-X simulator
#if !(defined(__APPLE__) && defined(I3D_ARCH_X86))
Director* pDirector = Director::sharedDirector();
Director* pDirector = Director::getInstance();
pDirector->getAccelerometer()->update((float)s3eAccelerometerGetX(), (float)s3eAccelerometerGetY(), (float)s3eAccelerometerGetZ(), s3eTimerGetMs()); // MH: Added casting to float
#endif
}

View File

@ -218,7 +218,7 @@ void EGLView::setIMEKeyboardState(bool bOpen)
}
}
EGLView* EGLView::sharedOpenGLView() // MH: Cocos2D now uses pointer instead of ref
EGLView* EGLView::getInstance() // MH: Cocos2D now uses pointer instead of ref
{
if( !_instance ) {
_instance = new EGLView() ;
@ -226,4 +226,10 @@ EGLView* EGLView::sharedOpenGLView() // MH: Cocos2D now uses pointer instead of
return _instance; // MH: Cocos2D now uses pointer instead of ref
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
NS_CC_END

View File

@ -48,7 +48,10 @@ public:
/**
@brief get the shared main open gl window
*/
static EGLView* sharedOpenGLView(); // MH: Cocos2D now uses pointer instead of ref
static EGLView* getInstance(); // MH: Cocos2D now uses pointer instead of ref
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
private:
bool _accelState;

View File

@ -9,7 +9,7 @@ using namespace std;
NS_CC_BEGIN
FileUtils* FileUtils::sharedFileUtils()
FileUtils* FileUtils::getInstance()
{
if (s_sharedFileUtils == NULL)
{

View File

@ -522,7 +522,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
IW_CALLSTACK("UIImage::initWithImageFile");
bool bRet = false;
unsigned long nSize = 0;
unsigned char* pBuffer = FileUtils::sharedFileUtils()->getFileData(strPath, "rb", &nSize);
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(strPath, "rb", &nSize);
if (pBuffer != NULL && nSize > 0)
{
bRet = initWithImageData(pBuffer, nSize, eImgFmt);
@ -536,7 +536,7 @@ bool Image::initWithImageFileThreadSafe( const char *fullpath, EImageFormat imag
CC_UNUSED_PARAM(imageType);
bool bRet = false;
unsigned long nSize = 0;
unsigned char *pBuffer = FileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize);
unsigned char *pBuffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &nSize);
if (pBuffer != NULL && nSize > 0)
{
bRet = initWithImageData(pBuffer, nSize, imageType);
@ -873,7 +873,7 @@ bool Image::initWithString(
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
fullFontName = FileUtils::sharedFileUtils()->fullPathForFilename(pFontName);
fullFontName = FileUtils::getInstance()->fullPathForFilename(pFontName);
}
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, fullFontName.c_str(), nSize));

View File

@ -69,8 +69,8 @@ int Application::run()
for (;;)
{
//long iLastTime = getCurrentMillSecond();
Director::sharedDirector()->mainLoop();
EGLView::sharedOpenGLView()->ProcessEventQueue();
Director::getInstance()->mainLoop();
EGLView::getInstance()->ProcessEventQueue();
//long iCurTime = getCurrentMillSecond();
/*

View File

@ -221,7 +221,7 @@ void EGLView::destroyGL()
CCLOG("destroyGL");
}
EGLView* EGLView::sharedOpenGLView()
EGLView* EGLView::getInstance()
{
static EGLView* s_pEglView = NULL;
if (s_pEglView == NULL)
@ -232,6 +232,12 @@ EGLView* EGLView::sharedOpenGLView()
return s_pEglView;
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
void EGLView::HandleMouseEvent(const pp::MouseInputEvent* event)
{
pp::Point pos = event->GetPosition();

View File

@ -70,7 +70,11 @@ public:
/**
@brief get the shared main open gl window
*/
static EGLView* sharedOpenGLView();
static EGLView* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
static CocosPepperInstance* g_instance;
private:
void HandleMouseEvent(const pp::MouseInputEvent* event);

View File

@ -30,7 +30,7 @@ using namespace std;
NS_CC_BEGIN
FileUtils* FileUtils::sharedFileUtils()
FileUtils* FileUtils::getInstance()
{
if (s_sharedFileUtils == NULL)
{

View File

@ -452,7 +452,7 @@ bool Image::initWithString(
BitmapDC &dc = sharedBitmapDC();
//const char* pFullFontName = FileUtils::sharedFileUtils()->fullPathFromRelativePath(pFontName);
//const char* pFullFontName = FileUtils::getInstance()->fullPathFromRelativePath(pFontName);
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFontName, nSize));

View File

@ -99,6 +99,6 @@ bool CocosPepperInstance::HandleInputEvent(const pp::InputEvent& event)
{
if (!Application::isRunning())
return false;
EGLView::sharedOpenGLView()->AddEvent(event);
EGLView::getInstance()->AddEvent(event);
return true;
}

View File

@ -99,7 +99,7 @@ void EGLView::setIMEKeyboardState(bool bOpen)
}
}
EGLView* EGLView::sharedOpenGLView()
EGLView* EGLView::getInstance()
{
static EGLView* s_pEglView = NULL;
if (s_pEglView == NULL)
@ -115,6 +115,12 @@ EGLView* EGLView::sharedOpenGLView()
return s_pEglView;
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
void
EGLView::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
{
@ -124,7 +130,7 @@ EGLView::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
}
__pTimer->Start(Application::sharedApplication()->getAnimationInterval());
Director::sharedDirector()->mainLoop();
Director::getInstance()->mainLoop();
}
bool

Some files were not shown because too many files have changed in this diff Show More