mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into socketio
This commit is contained in:
commit
4b2165e648
|
@ -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)
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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) ;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1 +1 @@
|
|||
abb8cd6d9aa6a69228983772b979c5b8a9a526ae
|
||||
3f4cd506dc44d54f375a2c759a90db69d845b75b
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
||||
|
@ -137,7 +143,7 @@ bool Director::init(void)
|
|||
// purge ?
|
||||
_purgeDirecotorInNextLoop = false;
|
||||
|
||||
_winSizeInPoints = SizeZero;
|
||||
_winSizeInPoints = Size::ZERO;
|
||||
|
||||
_openGLView = NULL;
|
||||
|
||||
|
@ -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
|
||||
|
@ -522,7 +528,7 @@ Point Director::convertToGL(const Point& uiPoint)
|
|||
kmVec3 glCoord;
|
||||
kmVec3TransformCoord(&glCoord, &clipCoord, &transformInv);
|
||||
|
||||
return ccp(glCoord.x, glCoord.y);
|
||||
return Point(glCoord.x, glCoord.y);
|
||||
}
|
||||
|
||||
Point Director::convertToUI(const Point& glPoint)
|
||||
|
@ -536,7 +542,7 @@ Point Director::convertToUI(const Point& glPoint)
|
|||
kmVec3TransformCoord(&clipCoord, &glCoord, &transform);
|
||||
|
||||
Size glSize = _openGLView->getDesignResolutionSize();
|
||||
return ccp(glSize.width*(clipCoord.x*0.5 + 0.5), glSize.height*(-clipCoord.y*0.5 + 0.5));
|
||||
return Point(glSize.width*(clipCoord.x*0.5 + 0.5), glSize.height*(-clipCoord.y*0.5 + 0.5));
|
||||
}
|
||||
|
||||
const Size& Director::getWinSize(void) const
|
||||
|
@ -546,7 +552,7 @@ const Size& Director::getWinSize(void) const
|
|||
|
||||
Size Director::getWinSizeInPixels() const
|
||||
{
|
||||
return CCSizeMake(_winSizeInPoints.width * _contentScaleFactor, _winSizeInPoints.height * _contentScaleFactor);
|
||||
return Size(_winSizeInPoints.width * _contentScaleFactor, _winSizeInPoints.height * _contentScaleFactor);
|
||||
}
|
||||
|
||||
Size Director::getVisibleSize() const
|
||||
|
@ -557,7 +563,7 @@ Size Director::getVisibleSize() const
|
|||
}
|
||||
else
|
||||
{
|
||||
return SizeZero;
|
||||
return Size::ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -569,7 +575,7 @@ Point Director::getVisibleOrigin() const
|
|||
}
|
||||
else
|
||||
{
|
||||
return PointZero;
|
||||
return Point::ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -912,8 +918,8 @@ void Director::createStatsLabel()
|
|||
|
||||
Texture2D::setDefaultAlphaPixelFormat(currentFormat);
|
||||
|
||||
_drawsLabel->setPosition(ccpAdd(ccp(0, 34*factor), CC_DIRECTOR_STATS_POSITION));
|
||||
_SPFLabel->setPosition(ccpAdd(ccp(0, 17*factor), CC_DIRECTOR_STATS_POSITION));
|
||||
_drawsLabel->setPosition(Point(0, 34*factor) + CC_DIRECTOR_STATS_POSITION);
|
||||
_SPFLabel->setPosition(Point(0, 17*factor) + CC_DIRECTOR_STATS_POSITION);
|
||||
_FPSLabel->setPosition(CC_DIRECTOR_STATS_POSITION);
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ Follow::~Follow()
|
|||
CC_SAFE_RELEASE(_followedNode);
|
||||
}
|
||||
|
||||
Follow* Follow::create(Node *pFollowedNode, const Rect& rect/* = RectZero*/)
|
||||
Follow* Follow::create(Node *pFollowedNode, const Rect& rect/* = Rect::ZERO*/)
|
||||
{
|
||||
Follow *pRet = new Follow();
|
||||
if (pRet && pRet->initWithTarget(pFollowedNode, rect))
|
||||
|
@ -190,14 +190,14 @@ Follow* Follow::clone() const
|
|||
return a;
|
||||
}
|
||||
|
||||
bool Follow::initWithTarget(Node *pFollowedNode, const Rect& rect/* = RectZero*/)
|
||||
bool Follow::initWithTarget(Node *pFollowedNode, const Rect& rect/* = Rect::ZERO*/)
|
||||
{
|
||||
CCAssert(pFollowedNode != NULL, "");
|
||||
|
||||
pFollowedNode->retain();
|
||||
_followedNode = pFollowedNode;
|
||||
_worldRect = rect;
|
||||
if (rect.equals(RectZero))
|
||||
if (rect.equals(Rect::ZERO))
|
||||
{
|
||||
_boundarySet = false;
|
||||
}
|
||||
|
@ -208,9 +208,9 @@ bool Follow::initWithTarget(Node *pFollowedNode, const Rect& rect/* = RectZero*/
|
|||
|
||||
_boundaryFullyCovered = false;
|
||||
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
_fullScreenSize = CCPointMake(winSize.width, winSize.height);
|
||||
_halfScreenSize = ccpMult(_fullScreenSize, 0.5f);
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
_fullScreenSize = Point(winSize.width, winSize.height);
|
||||
_halfScreenSize = _fullScreenSize * 0.5f;
|
||||
|
||||
if (_boundarySet)
|
||||
{
|
||||
|
@ -251,14 +251,14 @@ void Follow::step(float dt)
|
|||
if(_boundaryFullyCovered)
|
||||
return;
|
||||
|
||||
Point tempPos = ccpSub( _halfScreenSize, _followedNode->getPosition());
|
||||
Point tempPos = _halfScreenSize - _followedNode->getPosition();
|
||||
|
||||
_target->setPosition(ccp(clampf(tempPos.x, _leftBoundary, _rightBoundary),
|
||||
_target->setPosition(Point(clampf(tempPos.x, _leftBoundary, _rightBoundary),
|
||||
clampf(tempPos.y, _bottomBoundary, _topBoundary)));
|
||||
}
|
||||
else
|
||||
{
|
||||
_target->setPosition(ccpSub(_halfScreenSize, _followedNode->getPosition()));
|
||||
_target->setPosition(_halfScreenSize - _followedNode->getPosition());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ public:
|
|||
, _rightBoundary(0.0)
|
||||
, _topBoundary(0.0)
|
||||
, _bottomBoundary(0.0)
|
||||
, _worldRect(RectZero)
|
||||
, _worldRect(Rect::ZERO)
|
||||
{}
|
||||
virtual ~Follow(void);
|
||||
|
||||
|
@ -220,7 +220,7 @@ public:
|
|||
inline void setBoudarySet(bool bValue) { _boundarySet = bValue; }
|
||||
|
||||
/** initializes the action with a set boundary */
|
||||
bool initWithTarget(Node *pFollowedNode, const Rect& rect = RectZero);
|
||||
bool initWithTarget(Node *pFollowedNode, const Rect& rect = Rect::ZERO);
|
||||
|
||||
/** returns a clone of action */
|
||||
virtual Follow* clone() const;
|
||||
|
@ -230,9 +230,9 @@ public:
|
|||
|
||||
public:
|
||||
/** creates the action with a set boundary,
|
||||
It will work with no boundary if @param rect is equal to RectZero.
|
||||
It will work with no boundary if @param rect is equal to Rect::ZERO.
|
||||
*/
|
||||
static Follow* create(Node *pFollowedNode, const Rect& rect = RectZero);
|
||||
static Follow* create(Node *pFollowedNode, const Rect& rect = Rect::ZERO);
|
||||
protected:
|
||||
// node to follow
|
||||
Node *_followedNode;
|
||||
|
|
|
@ -215,7 +215,7 @@ Point ccCardinalSplineAt(Point &p0, Point &p1, Point &p2, Point &p3, float tensi
|
|||
float x = (p0.x*b1 + p1.x*b2 + p2.x*b3 + p3.x*b4);
|
||||
float y = (p0.y*b1 + p1.y*b2 + p2.y*b3 + p3.y*b4);
|
||||
|
||||
return ccp(x,y);
|
||||
return Point(x,y);
|
||||
}
|
||||
|
||||
/* Implementation of CardinalSplineTo
|
||||
|
@ -276,7 +276,7 @@ void CardinalSplineTo::startWithTarget(cocos2d::Node *pTarget)
|
|||
_deltaT = (float) 1 / (_points->count() - 1);
|
||||
|
||||
_previousPosition = pTarget->getPosition();
|
||||
_accumulatedDiff = PointZero;
|
||||
_accumulatedDiff = Point::ZERO;
|
||||
}
|
||||
|
||||
CardinalSplineTo* CardinalSplineTo::clone() const
|
||||
|
@ -319,10 +319,10 @@ void CardinalSplineTo::update(float time)
|
|||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
// Support for stacked actions
|
||||
Node *node = _target;
|
||||
Point diff = ccpSub( node->getPosition(), _previousPosition);
|
||||
Point diff = node->getPosition() - _previousPosition;
|
||||
if( diff.x !=0 || diff.y != 0 ) {
|
||||
_accumulatedDiff = ccpAdd( _accumulatedDiff, diff);
|
||||
newPos = ccpAdd( newPos, _accumulatedDiff);
|
||||
_accumulatedDiff = _accumulatedDiff + diff;
|
||||
newPos = newPos + _accumulatedDiff;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -369,7 +369,7 @@ CardinalSplineBy::CardinalSplineBy() : _startPosition(0,0)
|
|||
|
||||
void CardinalSplineBy::updatePosition(cocos2d::Point &newPos)
|
||||
{
|
||||
Point p = ccpAdd(newPos, _startPosition);
|
||||
Point p = newPos + _startPosition;
|
||||
_target->setPosition(p);
|
||||
_previousPosition = p;
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ CardinalSplineBy* CardinalSplineBy::reverse() const
|
|||
for (unsigned int i = 1; i < copyConfig->count(); ++i)
|
||||
{
|
||||
Point current = copyConfig->getControlPointAtIndex(i);
|
||||
Point diff = ccpSub(current, p);
|
||||
Point diff = current - p;
|
||||
copyConfig->replaceControlPoint(diff, i);
|
||||
|
||||
p = current;
|
||||
|
@ -401,14 +401,14 @@ CardinalSplineBy* CardinalSplineBy::reverse() const
|
|||
p = pReverse->getControlPointAtIndex(pReverse->count()-1);
|
||||
pReverse->removeControlPointAtIndex(pReverse->count()-1);
|
||||
|
||||
p = ccpNeg(p);
|
||||
p = -p;
|
||||
pReverse->insertControlPoint(p, 0);
|
||||
|
||||
for (unsigned int i = 1; i < pReverse->count(); ++i)
|
||||
{
|
||||
Point current = pReverse->getControlPointAtIndex(i);
|
||||
current = ccpNeg(current);
|
||||
Point abs = ccpAdd(current, p);
|
||||
current = -current;
|
||||
Point abs = current + p;
|
||||
pReverse->replaceControlPoint(abs, i);
|
||||
|
||||
p = abs;
|
||||
|
@ -530,7 +530,7 @@ CatmullRomBy* CatmullRomBy::reverse() const
|
|||
for (unsigned int i = 1; i < copyConfig->count(); ++i)
|
||||
{
|
||||
Point current = copyConfig->getControlPointAtIndex(i);
|
||||
Point diff = ccpSub(current, p);
|
||||
Point diff = current - p;
|
||||
copyConfig->replaceControlPoint(diff, i);
|
||||
|
||||
p = current;
|
||||
|
@ -546,14 +546,14 @@ CatmullRomBy* CatmullRomBy::reverse() const
|
|||
p = pReverse->getControlPointAtIndex(pReverse->count()-1);
|
||||
pReverse->removeControlPointAtIndex(pReverse->count()-1);
|
||||
|
||||
p = ccpNeg(p);
|
||||
p = -p;
|
||||
pReverse->insertControlPoint(p, 0);
|
||||
|
||||
for (unsigned int i = 1; i < pReverse->count(); ++i)
|
||||
{
|
||||
Point current = pReverse->getControlPointAtIndex(i);
|
||||
current = ccpNeg(current);
|
||||
Point abs = ccpAdd(current, p);
|
||||
current = -current;
|
||||
Point abs = current + p;
|
||||
pReverse->replaceControlPoint(abs, i);
|
||||
|
||||
p = abs;
|
||||
|
|
|
@ -79,10 +79,10 @@ void Waves3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||
{
|
||||
Vertex3F v = getOriginalVertex(ccp(i ,j));
|
||||
Vertex3F v = getOriginalVertex(Point(i ,j));
|
||||
v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * 0.01f) * _amplitude * _amplitudeRate);
|
||||
//CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate));
|
||||
setVertex(ccp(i, j), v);
|
||||
setVertex(Point(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ FlipX3D* FlipX3D::create(float duration)
|
|||
|
||||
bool FlipX3D::initWithDuration(float duration)
|
||||
{
|
||||
return Grid3DAction::initWithDuration(duration, CCSizeMake(1, 1));
|
||||
return Grid3DAction::initWithDuration(duration, Size(1, 1));
|
||||
}
|
||||
|
||||
bool FlipX3D::initWithSize(const Size& gridSize, float duration)
|
||||
|
@ -144,8 +144,8 @@ void FlipX3D::update(float time)
|
|||
|
||||
Vertex3F v0, v1, v, diff;
|
||||
|
||||
v0 = getOriginalVertex(ccp(1, 1));
|
||||
v1 = getOriginalVertex(ccp(0, 0));
|
||||
v0 = getOriginalVertex(Point(1, 1));
|
||||
v1 = getOriginalVertex(Point(0, 0));
|
||||
|
||||
float x0 = v0.x;
|
||||
float x1 = v1.x;
|
||||
|
@ -155,19 +155,19 @@ void FlipX3D::update(float time)
|
|||
if ( x0 > x1 )
|
||||
{
|
||||
// Normal Grid
|
||||
a = ccp(0,0);
|
||||
b = ccp(0,1);
|
||||
c = ccp(1,0);
|
||||
d = ccp(1,1);
|
||||
a = Point(0,0);
|
||||
b = Point(0,1);
|
||||
c = Point(1,0);
|
||||
d = Point(1,1);
|
||||
x = x0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reversed Grid
|
||||
c = ccp(0,0);
|
||||
d = ccp(0,1);
|
||||
a = ccp(1,0);
|
||||
b = ccp(1,1);
|
||||
c = Point(0,0);
|
||||
d = Point(0,1);
|
||||
a = Point(1,0);
|
||||
b = Point(1,1);
|
||||
x = x1;
|
||||
}
|
||||
|
||||
|
@ -238,8 +238,8 @@ void FlipY3D::update(float time)
|
|||
|
||||
Vertex3F v0, v1, v, diff;
|
||||
|
||||
v0 = getOriginalVertex(ccp(1, 1));
|
||||
v1 = getOriginalVertex(ccp(0, 0));
|
||||
v0 = getOriginalVertex(Point(1, 1));
|
||||
v1 = getOriginalVertex(Point(0, 0));
|
||||
|
||||
float y0 = v0.y;
|
||||
float y1 = v1.y;
|
||||
|
@ -249,19 +249,19 @@ void FlipY3D::update(float time)
|
|||
if (y0 > y1)
|
||||
{
|
||||
// Normal Grid
|
||||
a = ccp(0,0);
|
||||
b = ccp(0,1);
|
||||
c = ccp(1,0);
|
||||
d = ccp(1,1);
|
||||
a = Point(0,0);
|
||||
b = Point(0,1);
|
||||
c = Point(1,0);
|
||||
d = Point(1,1);
|
||||
y = y0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reversed Grid
|
||||
b = ccp(0,0);
|
||||
a = ccp(0,1);
|
||||
d = ccp(1,0);
|
||||
c = ccp(1,1);
|
||||
b = Point(0,0);
|
||||
a = Point(0,1);
|
||||
d = Point(1,0);
|
||||
c = Point(1,1);
|
||||
y = y1;
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Point&
|
|||
{
|
||||
if (Grid3DAction::initWithDuration(duration, gridSize))
|
||||
{
|
||||
_position = ccp(-1, -1);
|
||||
_position = Point(-1, -1);
|
||||
setPosition(position);
|
||||
_radius = radius;
|
||||
_lensEffect = 0.7f;
|
||||
|
@ -361,9 +361,9 @@ void Lens3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||
{
|
||||
Vertex3F v = getOriginalVertex(ccp(i, j));
|
||||
Point vect = ccpSub(_position, ccp(v.x, v.y));
|
||||
float r = ccpLength(vect);
|
||||
Vertex3F v = getOriginalVertex(Point(i, j));
|
||||
Point vect = _position - Point(v.x, v.y);
|
||||
float r = vect.getLength();
|
||||
|
||||
if (r < _radius)
|
||||
{
|
||||
|
@ -377,15 +377,15 @@ void Lens3D::update(float time)
|
|||
float l = logf(pre_log) * _lensEffect;
|
||||
float new_r = expf( l ) * _radius;
|
||||
|
||||
if (ccpLength(vect) > 0)
|
||||
if (vect.getLength() > 0)
|
||||
{
|
||||
vect = ccpNormalize(vect);
|
||||
Point new_vect = ccpMult(vect, new_r);
|
||||
v.z += (_concave ? -1.0f : 1.0f) * ccpLength(new_vect) * _lensEffect;
|
||||
vect = vect.normalize();
|
||||
Point new_vect = vect * new_r;
|
||||
v.z += (_concave ? -1.0f : 1.0f) * new_vect.getLength() * _lensEffect;
|
||||
}
|
||||
}
|
||||
|
||||
setVertex(ccp(i, j), v);
|
||||
setVertex(Point(i, j), v);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,9 +453,9 @@ void Ripple3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||
{
|
||||
Vertex3F v = getOriginalVertex(ccp(i, j));
|
||||
Point vect = ccpSub(_position, ccp(v.x,v.y));
|
||||
float r = ccpLength(vect);
|
||||
Vertex3F v = getOriginalVertex(Point(i, j));
|
||||
Point vect = _position - Point(v.x,v.y);
|
||||
float r = vect.getLength();
|
||||
|
||||
if (r < _radius)
|
||||
{
|
||||
|
@ -464,7 +464,7 @@ void Ripple3D::update(float time)
|
|||
v.z += (sinf( time*(float)M_PI * _waves * 2 + r * 0.1f) * _amplitude * _amplitudeRate * rate);
|
||||
}
|
||||
|
||||
setVertex(ccp(i, j), v);
|
||||
setVertex(Point(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ void Shaky3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||
{
|
||||
Vertex3F v = getOriginalVertex(ccp(i ,j));
|
||||
Vertex3F v = getOriginalVertex(Point(i ,j));
|
||||
v.x += (rand() % (_randrange*2)) - _randrange;
|
||||
v.y += (rand() % (_randrange*2)) - _randrange;
|
||||
if (_shakeZ)
|
||||
|
@ -529,7 +529,7 @@ void Shaky3D::update(float time)
|
|||
v.z += (rand() % (_randrange*2)) - _randrange;
|
||||
}
|
||||
|
||||
setVertex(ccp(i, j), v);
|
||||
setVertex(Point(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -586,10 +586,10 @@ void Liquid::update(float time)
|
|||
{
|
||||
for (j = 1; j < _gridSize.height; ++j)
|
||||
{
|
||||
Vertex3F v = getOriginalVertex(ccp(i, j));
|
||||
Vertex3F v = getOriginalVertex(Point(i, j));
|
||||
v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
|
||||
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate));
|
||||
setVertex(ccp(i, j), v);
|
||||
setVertex(Point(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -648,7 +648,7 @@ void Waves::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||
{
|
||||
Vertex3F v = getOriginalVertex(ccp(i, j));
|
||||
Vertex3F v = getOriginalVertex(Point(i, j));
|
||||
|
||||
if (_vertical)
|
||||
{
|
||||
|
@ -660,7 +660,7 @@ void Waves::update(float time)
|
|||
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
|
||||
}
|
||||
|
||||
setVertex(ccp(i, j), v);
|
||||
setVertex(Point(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -724,22 +724,22 @@ void Twirl::update(float time)
|
|||
{
|
||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||
{
|
||||
Vertex3F v = getOriginalVertex(ccp(i ,j));
|
||||
Vertex3F v = getOriginalVertex(Point(i ,j));
|
||||
|
||||
Point avg = ccp(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
|
||||
float r = ccpLength(avg);
|
||||
Point avg = Point(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
|
||||
float r = avg.getLength();
|
||||
|
||||
float amp = 0.1f * _amplitude * _amplitudeRate;
|
||||
float a = r * cosf( (float)M_PI/2.0f + time * (float)M_PI * _twirls * 2 ) * amp;
|
||||
|
||||
Point d = ccp(
|
||||
Point d = Point(
|
||||
sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x),
|
||||
cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x));
|
||||
|
||||
v.x = c.x + d.x;
|
||||
v.y = c.y + d.y;
|
||||
|
||||
setVertex(ccp(i ,j), v);
|
||||
setVertex(Point(i ,j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -924,7 +924,7 @@ void MoveBy::startWithTarget(Node *pTarget)
|
|||
|
||||
MoveBy* MoveBy::reverse() const
|
||||
{
|
||||
return MoveBy::create(_duration, ccp( -_positionDelta.x, -_positionDelta.y));
|
||||
return MoveBy::create(_duration, Point( -_positionDelta.x, -_positionDelta.y));
|
||||
}
|
||||
|
||||
|
||||
|
@ -934,9 +934,9 @@ void MoveBy::update(float t)
|
|||
{
|
||||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
Point currentPos = _target->getPosition();
|
||||
Point diff = ccpSub(currentPos, _previousPosition);
|
||||
_startPosition = ccpAdd( _startPosition, diff);
|
||||
Point newPos = ccpAdd( _startPosition, ccpMult(_positionDelta, t) );
|
||||
Point diff = currentPos - _previousPosition;
|
||||
_startPosition = _startPosition + diff;
|
||||
Point newPos = _startPosition + (_positionDelta * t);
|
||||
_target->setPosition(newPos);
|
||||
_previousPosition = newPos;
|
||||
#else
|
||||
|
@ -981,7 +981,7 @@ MoveTo* MoveTo::clone(void) const
|
|||
void MoveTo::startWithTarget(Node *pTarget)
|
||||
{
|
||||
MoveBy::startWithTarget(pTarget);
|
||||
_positionDelta = ccpSub( _endPosition, pTarget->getPosition() );
|
||||
_positionDelta = _endPosition - pTarget->getPosition();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1217,22 +1217,22 @@ void JumpBy::update(float t)
|
|||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
Point currentPos = _target->getPosition();
|
||||
|
||||
Point diff = ccpSub( currentPos, _previousPos );
|
||||
_startPosition = ccpAdd( diff, _startPosition);
|
||||
Point diff = currentPos - _previousPos;
|
||||
_startPosition = diff + _startPosition;
|
||||
|
||||
Point newPos = ccpAdd( _startPosition, ccp(x,y));
|
||||
Point newPos = _startPosition + Point(x,y);
|
||||
_target->setPosition(newPos);
|
||||
|
||||
_previousPos = newPos;
|
||||
#else
|
||||
_target->setPosition(ccpAdd( _startPosition, ccp(x,y)));
|
||||
_target->setPosition(ccpAdd( _startPosition, Point(x,y)));
|
||||
#endif // !CC_ENABLE_STACKABLE_ACTIONS
|
||||
}
|
||||
}
|
||||
|
||||
JumpBy* JumpBy::reverse() const
|
||||
{
|
||||
return JumpBy::create(_duration, ccp(-_delta.x, -_delta.y),
|
||||
return JumpBy::create(_duration, Point(-_delta.x, -_delta.y),
|
||||
_height, _jumps);
|
||||
}
|
||||
|
||||
|
@ -1267,7 +1267,7 @@ JumpTo* JumpTo::reverse() const
|
|||
void JumpTo::startWithTarget(Node *pTarget)
|
||||
{
|
||||
JumpBy::startWithTarget(pTarget);
|
||||
_delta = ccp(_delta.x - _startPosition.x, _delta.y - _startPosition.y);
|
||||
_delta = Point(_delta.x - _startPosition.x, _delta.y - _startPosition.y);
|
||||
}
|
||||
|
||||
// Bezier cubic formula:
|
||||
|
@ -1340,15 +1340,15 @@ void BezierBy::update(float time)
|
|||
|
||||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
Point currentPos = _target->getPosition();
|
||||
Point diff = ccpSub(currentPos, _previousPosition);
|
||||
_startPosition = ccpAdd( _startPosition, diff);
|
||||
Point diff = currentPos - _previousPosition;
|
||||
_startPosition = _startPosition + diff;
|
||||
|
||||
Point newPos = ccpAdd( _startPosition, ccp(x,y));
|
||||
Point newPos = _startPosition + Point(x,y);
|
||||
_target->setPosition(newPos);
|
||||
|
||||
_previousPosition = newPos;
|
||||
#else
|
||||
_target->setPosition(ccpAdd( _startPosition, ccp(x,y)));
|
||||
_target->setPosition(ccpAdd( _startPosition, Point(x,y)));
|
||||
#endif // !CC_ENABLE_STACKABLE_ACTIONS
|
||||
}
|
||||
}
|
||||
|
@ -1357,9 +1357,9 @@ BezierBy* BezierBy::reverse(void) const
|
|||
{
|
||||
ccBezierConfig r;
|
||||
|
||||
r.endPosition = ccpNeg(_config.endPosition);
|
||||
r.controlPoint_1 = ccpAdd(_config.controlPoint_2, ccpNeg(_config.endPosition));
|
||||
r.controlPoint_2 = ccpAdd(_config.controlPoint_1, ccpNeg(_config.endPosition));
|
||||
r.endPosition = -_config.endPosition;
|
||||
r.controlPoint_1 = _config.controlPoint_2 + (-_config.endPosition);
|
||||
r.controlPoint_2 = _config.controlPoint_1 + (-_config.endPosition);
|
||||
|
||||
BezierBy *pAction = BezierBy::create(_duration, r);
|
||||
return pAction;
|
||||
|
@ -1401,9 +1401,9 @@ BezierTo* BezierTo::clone(void) const
|
|||
void BezierTo::startWithTarget(Node *pTarget)
|
||||
{
|
||||
BezierBy::startWithTarget(pTarget);
|
||||
_config.controlPoint_1 = ccpSub(_toConfig.controlPoint_1, _startPosition);
|
||||
_config.controlPoint_2 = ccpSub(_toConfig.controlPoint_2, _startPosition);
|
||||
_config.endPosition = ccpSub(_toConfig.endPosition, _startPosition);
|
||||
_config.controlPoint_1 = _toConfig.controlPoint_1 - _startPosition;
|
||||
_config.controlPoint_2 = _toConfig.controlPoint_2 - _startPosition;
|
||||
_config.endPosition = _toConfig.endPosition - _startPosition;
|
||||
}
|
||||
|
||||
BezierTo* BezierTo::reverse() const
|
||||
|
|
|
@ -76,7 +76,7 @@ void PageTurn3D::update(float time)
|
|||
for (int j = 0; j <= _gridSize.height; ++j)
|
||||
{
|
||||
// Get original vertex
|
||||
Vertex3F p = getOriginalVertex(ccp(i ,j));
|
||||
Vertex3F p = getOriginalVertex(Point(i ,j));
|
||||
|
||||
float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay)));
|
||||
float r = R * sinTheta;
|
||||
|
@ -111,7 +111,7 @@ void PageTurn3D::update(float time)
|
|||
}
|
||||
|
||||
// Set new coords
|
||||
setVertex(ccp(i, j), p);
|
||||
setVertex(Point(i, j), p);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ void ShakyTiles3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(ccp(i, j));
|
||||
Quad3 coords = getOriginalTile(Point(i, j));
|
||||
|
||||
// X
|
||||
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
|
||||
|
@ -112,7 +112,7 @@ void ShakyTiles3D::update(float time)
|
|||
coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
|
||||
}
|
||||
|
||||
setTile(ccp(i, j), coords);
|
||||
setTile(Point(i, j), coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ void ShatteredTiles3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(ccp(i ,j));
|
||||
Quad3 coords = getOriginalTile(Point(i ,j));
|
||||
|
||||
// X
|
||||
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
|
||||
|
@ -194,7 +194,7 @@ void ShatteredTiles3D::update(float time)
|
|||
coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
|
||||
}
|
||||
|
||||
setTile(ccp(i, j), coords);
|
||||
setTile(Point(i, j), coords);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ Size ShuffleTiles::getDelta(const Size& pos) const
|
|||
pos2.x = (float)(_tilesOrder[idx] / (int)_gridSize.height);
|
||||
pos2.y = (float)(_tilesOrder[idx] % (int)_gridSize.height);
|
||||
|
||||
return CCSizeMake((int)(pos2.x - pos.width), (int)(pos2.y - pos.height));
|
||||
return Size((int)(pos2.x - pos.width), (int)(pos2.y - pos.height));
|
||||
}
|
||||
|
||||
void ShuffleTiles::placeTile(const Point& pos, Tile *t)
|
||||
|
@ -328,9 +328,9 @@ void ShuffleTiles::startWithTarget(Node *pTarget)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
tileArray->position = ccp((float)i, (float)j);
|
||||
tileArray->startPosition = ccp((float)i, (float)j);
|
||||
tileArray->delta = getDelta(CCSizeMake(i, j));
|
||||
tileArray->position = Point((float)i, (float)j);
|
||||
tileArray->startPosition = Point((float)i, (float)j);
|
||||
tileArray->delta = getDelta(Size(i, j));
|
||||
++tileArray;
|
||||
}
|
||||
}
|
||||
|
@ -346,8 +346,8 @@ void ShuffleTiles::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
tileArray->position = ccpMult(ccp((float)tileArray->delta.width, (float)tileArray->delta.height), time);
|
||||
placeTile(ccp(i, j), tileArray);
|
||||
tileArray->position = Point((float)tileArray->delta.width, (float)tileArray->delta.height) * time;
|
||||
placeTile(Point(i, j), tileArray);
|
||||
++tileArray;
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ FadeOutTRTiles* FadeOutTRTiles::clone() const
|
|||
|
||||
float FadeOutTRTiles::testFunc(const Size& pos, float time)
|
||||
{
|
||||
Point n = ccpMult(ccp((float)_gridSize.width, (float)_gridSize.height), time);
|
||||
Point n = Point((float)_gridSize.width, (float)_gridSize.height) * time;
|
||||
if ((n.x + n.y) == 0.0f)
|
||||
{
|
||||
return 1.0f;
|
||||
|
@ -434,18 +434,18 @@ void FadeOutTRTiles::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
float distance = testFunc(CCSizeMake(i, j), time);
|
||||
float distance = testFunc(Size(i, j), time);
|
||||
if ( distance == 0 )
|
||||
{
|
||||
turnOffTile(ccp(i, j));
|
||||
turnOffTile(Point(i, j));
|
||||
} else
|
||||
if (distance < 1)
|
||||
{
|
||||
transformTile(ccp(i, j), distance);
|
||||
transformTile(Point(i, j), distance);
|
||||
}
|
||||
else
|
||||
{
|
||||
turnOnTile(ccp(i, j));
|
||||
turnOnTile(Point(i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ FadeOutBLTiles* FadeOutBLTiles::clone() const
|
|||
|
||||
float FadeOutBLTiles::testFunc(const Size& pos, float time)
|
||||
{
|
||||
Point n = ccpMult(ccp((float)_gridSize.width, (float)_gridSize.height), (1.0f - time));
|
||||
Point n = Point((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
|
||||
if ((pos.width + pos.height) == 0)
|
||||
{
|
||||
return 1.0f;
|
||||
|
@ -524,7 +524,7 @@ FadeOutUpTiles* FadeOutUpTiles::clone() const
|
|||
|
||||
float FadeOutUpTiles::testFunc(const Size& pos, float time)
|
||||
{
|
||||
Point n = ccpMult(ccp((float)_gridSize.width, (float)_gridSize.height), time);
|
||||
Point n = Point((float)_gridSize.width, (float)_gridSize.height) * time;
|
||||
if (n.y == 0.0f)
|
||||
{
|
||||
return 1.0f;
|
||||
|
@ -578,7 +578,7 @@ FadeOutDownTiles* FadeOutDownTiles::clone() const
|
|||
|
||||
float FadeOutDownTiles::testFunc(const Size& pos, float time)
|
||||
{
|
||||
Point n = ccpMult(ccp((float)_gridSize.width, (float)_gridSize.height), (1.0f - time));
|
||||
Point n = Point((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
|
||||
if (pos.height == 0)
|
||||
{
|
||||
return 1.0f;
|
||||
|
@ -705,7 +705,7 @@ void TurnOffTiles::update(float time)
|
|||
for( i = 0; i < _tilesCount; i++ )
|
||||
{
|
||||
t = _tilesOrder[i];
|
||||
Point tilePos = ccp( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height );
|
||||
Point tilePos = Point( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height );
|
||||
|
||||
if ( i < l )
|
||||
{
|
||||
|
@ -770,7 +770,7 @@ void WavesTiles3D::update(float time)
|
|||
{
|
||||
for( j = 0; j < _gridSize.height; j++ )
|
||||
{
|
||||
Quad3 coords = getOriginalTile(ccp(i, j));
|
||||
Quad3 coords = getOriginalTile(Point(i, j));
|
||||
|
||||
coords.bl.z = (sinf(time * (float)M_PI *_waves * 2 +
|
||||
(coords.bl.y+coords.bl.x) * .01f) * _amplitude * _amplitudeRate );
|
||||
|
@ -778,7 +778,7 @@ void WavesTiles3D::update(float time)
|
|||
coords.tl.z = coords.bl.z;
|
||||
coords.tr.z = coords.bl.z;
|
||||
|
||||
setTile(ccp(i, j), coords);
|
||||
setTile(Point(i, j), coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -838,7 +838,7 @@ void JumpTiles3D::update(float time)
|
|||
{
|
||||
for( j = 0; j < _gridSize.height; j++ )
|
||||
{
|
||||
Quad3 coords = getOriginalTile(ccp(i, j));
|
||||
Quad3 coords = getOriginalTile(Point(i, j));
|
||||
|
||||
if ( ((i+j) % 2) == 0 )
|
||||
{
|
||||
|
@ -855,7 +855,7 @@ void JumpTiles3D::update(float time)
|
|||
coords.tr.z += sinz2;
|
||||
}
|
||||
|
||||
setTile(ccp(i, j), coords);
|
||||
setTile(Point(i, j), coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -885,7 +885,7 @@ bool SplitRows::initWithDuration(float duration, unsigned int nRows)
|
|||
{
|
||||
_rows = nRows;
|
||||
|
||||
return TiledGrid3DAction::initWithDuration(duration, CCSizeMake(1, nRows));
|
||||
return TiledGrid3DAction::initWithDuration(duration, Size(1, nRows));
|
||||
}
|
||||
|
||||
SplitRows* SplitRows::clone() const
|
||||
|
@ -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)
|
||||
|
@ -909,7 +909,7 @@ void SplitRows::update(float time)
|
|||
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(ccp(0, j));
|
||||
Quad3 coords = getOriginalTile(Point(0, j));
|
||||
float direction = 1;
|
||||
|
||||
if ( (j % 2 ) == 0 )
|
||||
|
@ -922,7 +922,7 @@ void SplitRows::update(float time)
|
|||
coords.tl.x += direction * _winSize.width * time;
|
||||
coords.tr.x += direction * _winSize.width * time;
|
||||
|
||||
setTile(ccp(0, j), coords);
|
||||
setTile(Point(0, j), coords);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -950,7 +950,7 @@ SplitCols* SplitCols::create(float duration, unsigned int nCols)
|
|||
bool SplitCols::initWithDuration(float duration, unsigned int nCols)
|
||||
{
|
||||
_cols = nCols;
|
||||
return TiledGrid3DAction::initWithDuration(duration, CCSizeMake(nCols, 1));
|
||||
return TiledGrid3DAction::initWithDuration(duration, Size(nCols, 1));
|
||||
}
|
||||
|
||||
SplitCols* SplitCols::clone() const
|
||||
|
@ -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)
|
||||
|
@ -974,7 +974,7 @@ void SplitCols::update(float time)
|
|||
|
||||
for (i = 0; i < _gridSize.width; ++i)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(ccp(i, 0));
|
||||
Quad3 coords = getOriginalTile(Point(i, 0));
|
||||
float direction = 1;
|
||||
|
||||
if ( (i % 2 ) == 0 )
|
||||
|
@ -987,7 +987,7 @@ void SplitCols::update(float time)
|
|||
coords.tl.y += direction * _winSize.height * time;
|
||||
coords.tr.y += direction * _winSize.height * time;
|
||||
|
||||
setTile(ccp(i, 0), coords);
|
||||
setTile(Point(i, 0), coords);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -58,12 +58,12 @@ Node::Node(void)
|
|||
, _scaleX(1.0f)
|
||||
, _scaleY(1.0f)
|
||||
, _vertexZ(0.0f)
|
||||
, _position(PointZero)
|
||||
, _position(Point::ZERO)
|
||||
, _skewX(0.0f)
|
||||
, _skewY(0.0f)
|
||||
, _anchorPointInPoints(PointZero)
|
||||
, _anchorPoint(PointZero)
|
||||
, _contentSize(SizeZero)
|
||||
, _anchorPointInPoints(Point::ZERO)
|
||||
, _anchorPoint(Point::ZERO)
|
||||
, _contentSize(Size::ZERO)
|
||||
, _additionalTransform(AffineTransformMakeIdentity())
|
||||
, _camera(NULL)
|
||||
// children (lazy allocs)
|
||||
|
@ -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();
|
||||
|
@ -305,7 +305,7 @@ void Node::getPosition(float* x, float* y) const
|
|||
|
||||
void Node::setPosition(float x, float y)
|
||||
{
|
||||
setPosition(ccp(x, y));
|
||||
setPosition(Point(x, y));
|
||||
}
|
||||
|
||||
float Node::getPositionX(void) const
|
||||
|
@ -320,12 +320,12 @@ float Node::getPositionY(void) const
|
|||
|
||||
void Node::setPositionX(float x)
|
||||
{
|
||||
setPosition(ccp(x, _position.y));
|
||||
setPosition(Point(x, _position.y));
|
||||
}
|
||||
|
||||
void Node::setPositionY(float y)
|
||||
{
|
||||
setPosition(ccp(_position.x, y));
|
||||
setPosition(Point(_position.x, y));
|
||||
}
|
||||
|
||||
/// children getter
|
||||
|
@ -394,7 +394,7 @@ void Node::setAnchorPoint(const Point& point)
|
|||
if( ! point.equals(_anchorPoint))
|
||||
{
|
||||
_anchorPoint = point;
|
||||
_anchorPointInPoints = ccp(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_transformDirty = _inverseDirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ void Node::setContentSize(const Size & size)
|
|||
{
|
||||
_contentSize = size;
|
||||
|
||||
_anchorPointInPoints = ccp(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_transformDirty = _inverseDirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ void Node::setShaderProgram(GLProgram *pShaderProgram)
|
|||
|
||||
Rect Node::boundingBox()
|
||||
{
|
||||
Rect rect = CCRectMake(0, 0, _contentSize.width, _contentSize.height);
|
||||
Rect rect = Rect(0, 0, _contentSize.width, _contentSize.height);
|
||||
return RectApplyAffineTransform(rect, nodeToParentTransform());
|
||||
}
|
||||
|
||||
|
@ -1204,7 +1204,7 @@ AffineTransform Node::nodeToParentTransform(void)
|
|||
// optimization:
|
||||
// inline anchor point calculation if skew is not needed
|
||||
// Adjusted transform calculation for rotational skew
|
||||
if (! needsSkewMatrix && !_anchorPointInPoints.equals(PointZero))
|
||||
if (! needsSkewMatrix && !_anchorPointInPoints.equals(Point::ZERO))
|
||||
{
|
||||
x += cy * -_anchorPointInPoints.x * _scaleX + -sx * -_anchorPointInPoints.y * _scaleY;
|
||||
y += sy * -_anchorPointInPoints.x * _scaleX + cx * -_anchorPointInPoints.y * _scaleY;
|
||||
|
@ -1227,7 +1227,7 @@ AffineTransform Node::nodeToParentTransform(void)
|
|||
_transform = AffineTransformConcat(skewMatrix, _transform);
|
||||
|
||||
// adjust anchor point
|
||||
if (!_anchorPointInPoints.equals(PointZero))
|
||||
if (!_anchorPointInPoints.equals(Point::ZERO))
|
||||
{
|
||||
_transform = AffineTransformTranslate(_transform, -_anchorPointInPoints.x, -_anchorPointInPoints.y);
|
||||
}
|
||||
|
@ -1292,19 +1292,19 @@ Point Node::convertToWorldSpace(const Point& nodePoint)
|
|||
Point Node::convertToNodeSpaceAR(const Point& worldPoint)
|
||||
{
|
||||
Point nodePoint = convertToNodeSpace(worldPoint);
|
||||
return ccpSub(nodePoint, _anchorPointInPoints);
|
||||
return nodePoint - _anchorPointInPoints;
|
||||
}
|
||||
|
||||
Point Node::convertToWorldSpaceAR(const Point& nodePoint)
|
||||
{
|
||||
Point pt = ccpAdd(nodePoint, _anchorPointInPoints);
|
||||
Point pt = nodePoint + _anchorPointInPoints;
|
||||
return convertToWorldSpace(pt);
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -276,12 +276,12 @@ public:
|
|||
/**
|
||||
* Changes the position (x,y) of the node in OpenGL coordinates
|
||||
*
|
||||
* Usually we use ccp(x,y) to compose Point object.
|
||||
* Usually we use Point(x,y) to compose Point object.
|
||||
* 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();
|
||||
* node->setPosition( ccp(size.width/2, size.height/2) )
|
||||
* Size size = Director::getInstance()->getWinSize();
|
||||
* node->setPosition( Point(size.width/2, size.height/2) )
|
||||
* @endcode
|
||||
*
|
||||
* @param position The position (x,y) of the node in OpenGL coordinates
|
||||
|
@ -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.
|
||||
|
@ -1273,7 +1273,7 @@ public:
|
|||
this->addChild(spriteB);
|
||||
|
||||
//position
|
||||
spriteA->setPosition(ccp(200, 200));
|
||||
spriteA->setPosition(Point(200, 200));
|
||||
|
||||
// Gets the spriteA's transform.
|
||||
AffineTransform t = spriteA->nodeToParentTransform();
|
||||
|
@ -1448,8 +1448,8 @@ public:
|
|||
protected:
|
||||
GLubyte _displayedOpacity;
|
||||
GLubyte _realOpacity;
|
||||
Color3B _displayedColor;
|
||||
Color3B _realColor;
|
||||
Color3B _displayedColor;
|
||||
Color3B _realColor;
|
||||
bool _cascadeColorEnabled;
|
||||
bool _cascadeOpacityEnabled;
|
||||
};
|
||||
|
|
|
@ -69,17 +69,17 @@ Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineT
|
|||
float right = rect.getMaxX();
|
||||
float bottom = rect.getMaxY();
|
||||
|
||||
Point topLeft = PointApplyAffineTransform(CCPointMake(left, top), anAffineTransform);
|
||||
Point topRight = PointApplyAffineTransform(CCPointMake(right, top), anAffineTransform);
|
||||
Point bottomLeft = PointApplyAffineTransform(CCPointMake(left, bottom), anAffineTransform);
|
||||
Point bottomRight = PointApplyAffineTransform(CCPointMake(right, bottom), anAffineTransform);
|
||||
Point topLeft = PointApplyAffineTransform(Point(left, top), anAffineTransform);
|
||||
Point topRight = PointApplyAffineTransform(Point(right, top), anAffineTransform);
|
||||
Point bottomLeft = PointApplyAffineTransform(Point(left, bottom), anAffineTransform);
|
||||
Point bottomRight = PointApplyAffineTransform(Point(right, bottom), anAffineTransform);
|
||||
|
||||
float minX = min(min(topLeft.x, topRight.x), min(bottomLeft.x, bottomRight.x));
|
||||
float maxX = max(max(topLeft.x, topRight.x), max(bottomLeft.x, bottomRight.x));
|
||||
float minY = min(min(topLeft.y, topRight.y), min(bottomLeft.y, bottomRight.y));
|
||||
float maxY = max(max(topLeft.y, topRight.y), max(bottomLeft.y, bottomRight.y));
|
||||
|
||||
return CCRectMake(minX, minY, (maxX - minX), (maxY - minY));
|
||||
return Rect(minX, minY, (maxX - minX), (maxY - minY));
|
||||
}
|
||||
|
||||
AffineTransform AffineTransformTranslate(const AffineTransform& t, float tx, float ty)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -116,6 +116,80 @@ Point Point::rotateByAngle(const Point& pivot, float angle) const
|
|||
return pivot + (*this - pivot).rotate(Point::forAngle(angle));
|
||||
}
|
||||
|
||||
bool Point::isLineIntersect(const Point& A, const Point& B,
|
||||
const Point& C, const Point& D,
|
||||
float *S, float *T)
|
||||
{
|
||||
// FAIL: Line undefined
|
||||
if ( (A.x==B.x && A.y==B.y) || (C.x==D.x && C.y==D.y) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const float BAx = B.x - A.x;
|
||||
const float BAy = B.y - A.y;
|
||||
const float DCx = D.x - C.x;
|
||||
const float DCy = D.y - C.y;
|
||||
const float ACx = A.x - C.x;
|
||||
const float ACy = A.y - C.y;
|
||||
|
||||
const float denom = DCy*BAx - DCx*BAy;
|
||||
|
||||
*S = DCx*ACy - DCy*ACx;
|
||||
*T = BAx*ACy - BAy*ACx;
|
||||
|
||||
if (denom == 0)
|
||||
{
|
||||
if (*S == 0 || *T == 0)
|
||||
{
|
||||
// Lines incident
|
||||
return true;
|
||||
}
|
||||
// Lines parallel and not incident
|
||||
return false;
|
||||
}
|
||||
|
||||
*S = *S / denom;
|
||||
*T = *T / denom;
|
||||
|
||||
// Point of intersection
|
||||
// CGPoint P;
|
||||
// P.x = A.x + *S * (B.x - A.x);
|
||||
// P.y = A.y + *S * (B.y - A.y);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Point::isSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D)
|
||||
{
|
||||
float S, T;
|
||||
|
||||
if (isLineIntersect(A, B, C, D, &S, &T )&&
|
||||
(S >= 0.0f && S <= 1.0f && T >= 0.0f && T <= 1.0f))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Point Point::getIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D)
|
||||
{
|
||||
float S, T;
|
||||
|
||||
if (isLineIntersect(A, B, C, D, &S, &T))
|
||||
{
|
||||
// Point of intersection
|
||||
Point P;
|
||||
P.x = A.x + S * (B.x - A.x);
|
||||
P.y = A.y + S * (B.y - A.y);
|
||||
return P;
|
||||
}
|
||||
|
||||
return Point::ZERO;
|
||||
}
|
||||
|
||||
const Point Point::ZERO = Point(0, 0);
|
||||
|
||||
// implementation of Size
|
||||
|
||||
Size::Size(void) : width(0), height(0)
|
||||
|
@ -179,6 +253,8 @@ bool Size::equals(const Size& target) const
|
|||
&& (fabs(this->height - target.height) < FLT_EPSILON);
|
||||
}
|
||||
|
||||
const Size Size::ZERO = Size(0, 0);
|
||||
|
||||
// implementation of Rect
|
||||
|
||||
Rect::Rect(void)
|
||||
|
@ -311,4 +387,6 @@ Rect Rect::unionWithRect(const Rect & rect) const
|
|||
return Rect(combinedLeftX, combinedBottomY, combinedRightX - combinedLeftX, combinedTopY - combinedBottomY);
|
||||
}
|
||||
|
||||
const Rect Rect::ZERO = Rect(0, 0, 0, 0);
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -25,12 +25,26 @@ THE SOFTWARE.
|
|||
#ifndef __CCGEMETRY_H__
|
||||
#define __CCGEMETRY_H__
|
||||
|
||||
#include <math.h>
|
||||
#include <functional>
|
||||
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
#include "CCObject.h"
|
||||
#include <math.h>
|
||||
#include "ccMacros.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/** Clamp a value between from and to.
|
||||
@since v0.99.1
|
||||
*/
|
||||
inline float clampf(float value, float min_inclusive, float max_inclusive)
|
||||
{
|
||||
if (min_inclusive > max_inclusive) {
|
||||
CC_SWAP(min_inclusive, max_inclusive, float);
|
||||
}
|
||||
return value < min_inclusive ? min_inclusive : value < max_inclusive? value : max_inclusive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @addtogroup data_structures
|
||||
* @{
|
||||
|
@ -132,6 +146,35 @@ public:
|
|||
inline Point getPerp() const {
|
||||
return Point(-y, x);
|
||||
};
|
||||
|
||||
/** Calculates midpoint between two points.
|
||||
@return Point
|
||||
@since v3.0
|
||||
*/
|
||||
inline Point getMidpoint(const Point& other) const
|
||||
{
|
||||
return Point((x + other.x) / 2.0f, (y + other.y) / 2.0f);
|
||||
}
|
||||
|
||||
/** Clamp a point between from and to.
|
||||
@since v3.0
|
||||
*/
|
||||
inline Point getClampPoint(const Point& min_inclusive, const Point& max_inclusive) const
|
||||
{
|
||||
return Point(clampf(x,min_inclusive.x,max_inclusive.x), clampf(y, min_inclusive.y, max_inclusive.y));
|
||||
}
|
||||
|
||||
/** Run a math operation function on each point component
|
||||
* absf, fllorf, ceilf, roundf
|
||||
* any function that has the signature: float func(float);
|
||||
* For example: let's try to take the floor of x,y
|
||||
* p.compOp(floorf);
|
||||
@since v3.0
|
||||
*/
|
||||
inline Point compOp(std::function<float(float)> function) const
|
||||
{
|
||||
return Point(function(x), function(y));
|
||||
}
|
||||
|
||||
/** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0
|
||||
@return Point
|
||||
|
@ -201,6 +244,45 @@ public:
|
|||
{
|
||||
return Point(cosf(a), sinf(a));
|
||||
}
|
||||
|
||||
/** A general line-line intersection test
|
||||
@param p1
|
||||
is the startpoint for the first line P1 = (p1 - p2)
|
||||
@param p2
|
||||
is the endpoint for the first line P1 = (p1 - p2)
|
||||
@param p3
|
||||
is the startpoint for the second line P2 = (p3 - p4)
|
||||
@param p4
|
||||
is the endpoint for the second line P2 = (p3 - p4)
|
||||
@param s
|
||||
is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1))
|
||||
@param t
|
||||
is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3))
|
||||
@return bool
|
||||
indicating successful intersection of a line
|
||||
note that to truly test intersection for segments we have to make
|
||||
sure that s & t lie within [0..1] and for rays, make sure s & t > 0
|
||||
the hit point is p3 + t * (p4 - p3);
|
||||
the hit point also is p1 + s * (p2 - p1);
|
||||
@since 3.0
|
||||
*/
|
||||
static bool isLineIntersect(const Point& A, const Point& B,
|
||||
const Point& C, const Point& D,
|
||||
float *S, float *T);
|
||||
|
||||
/*
|
||||
returns YES if Segment A-B intersects with segment C-D
|
||||
@since v3.0
|
||||
*/
|
||||
static bool isSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D);
|
||||
|
||||
/*
|
||||
returns the intersection point of line A-B, C-D
|
||||
@since v3.0
|
||||
*/
|
||||
static Point getIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D);
|
||||
|
||||
static const Point ZERO;
|
||||
};
|
||||
|
||||
class CC_DLL Size
|
||||
|
@ -222,6 +304,8 @@ public:
|
|||
Size operator/(float a) const;
|
||||
void setSize(float width, float height);
|
||||
bool equals(const Size& target) const;
|
||||
|
||||
static const Size ZERO;
|
||||
};
|
||||
|
||||
class CC_DLL Rect
|
||||
|
@ -246,21 +330,34 @@ public:
|
|||
bool containsPoint(const Point& point) const;
|
||||
bool intersectsRect(const Rect& rect) const;
|
||||
Rect unionWithRect(const Rect & rect) const;
|
||||
|
||||
static const Rect ZERO;
|
||||
};
|
||||
|
||||
|
||||
#define CCPointMake(x, y) Point((float)(x), (float)(y))
|
||||
#define CCSizeMake(width, height) Size((float)(width), (float)(height))
|
||||
#define CCRectMake(x, y, width, height) Rect((float)(x), (float)(y), (float)(width), (float)(height))
|
||||
CC_DEPRECATED_ATTRIBUTE inline Point CCPointMake(float x, float y)
|
||||
{
|
||||
return Point(x, y);
|
||||
}
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE inline Size CCSizeMake(float width, float height)
|
||||
{
|
||||
return Size(width, height);
|
||||
}
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE inline Rect CCRectMake(float x, float y, float width, float height)
|
||||
{
|
||||
return Rect(x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
const Point PointZero = CCPointMake(0,0);
|
||||
CC_DEPRECATED_ATTRIBUTE const Point PointZero = Point::ZERO;
|
||||
|
||||
/* The "zero" size -- equivalent to CCSizeMake(0, 0). */
|
||||
const Size SizeZero = CCSizeMake(0,0);
|
||||
/* The "zero" size -- equivalent to Size(0, 0). */
|
||||
CC_DEPRECATED_ATTRIBUTE const Size SizeZero = Size::ZERO;
|
||||
|
||||
/* The "zero" rectangle -- equivalent to CCRectMake(0, 0, 0, 0). */
|
||||
const Rect RectZero = CCRectMake(0,0,0,0);
|
||||
/* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */
|
||||
CC_DEPRECATED_ATTRIBUTE const Rect RectZero = Rect::ZERO;
|
||||
|
||||
// end of data_structure group
|
||||
/// @}
|
||||
|
|
|
@ -99,7 +99,7 @@ static bool splitWithForm(const char* pStr, strArray& strs)
|
|||
|
||||
Rect RectFromString(const char* pszContent)
|
||||
{
|
||||
Rect result = RectZero;
|
||||
Rect result = Rect::ZERO;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -140,7 +140,7 @@ Rect RectFromString(const char* pszContent)
|
|||
float width = (float) atof(sizeInfo[0].c_str());
|
||||
float height = (float) atof(sizeInfo[1].c_str());
|
||||
|
||||
result = CCRectMake(x, y, width, height);
|
||||
result = Rect(x, y, width, height);
|
||||
} while (0);
|
||||
|
||||
return result;
|
||||
|
@ -148,7 +148,7 @@ Rect RectFromString(const char* pszContent)
|
|||
|
||||
Point PointFromString(const char* pszContent)
|
||||
{
|
||||
Point ret = PointZero;
|
||||
Point ret = Point::ZERO;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -158,7 +158,7 @@ Point PointFromString(const char* pszContent)
|
|||
float x = (float) atof(strs[0].c_str());
|
||||
float y = (float) atof(strs[1].c_str());
|
||||
|
||||
ret = CCPointMake(x, y);
|
||||
ret = Point(x, y);
|
||||
} while (0);
|
||||
|
||||
return ret;
|
||||
|
@ -166,7 +166,7 @@ Point PointFromString(const char* pszContent)
|
|||
|
||||
Size SizeFromString(const char* pszContent)
|
||||
{
|
||||
Size ret = SizeZero;
|
||||
Size ret = Size::ZERO;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -176,7 +176,7 @@ Size SizeFromString(const char* pszContent)
|
|||
float width = (float) atof(strs[0].c_str());
|
||||
float height = (float) atof(strs[1].c_str());
|
||||
|
||||
ret = CCSizeMake(width, height);
|
||||
ret = Size(width, height);
|
||||
} while (0);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -42,7 +42,7 @@ NS_CC_BEGIN
|
|||
An example of a valid string is "{{3,2},{4,5}}".
|
||||
The string is not localized, so items are always separated with a comma.
|
||||
@return A Core Graphics structure that represents a rectangle.
|
||||
If the string is not well-formed, the function returns RectZero.
|
||||
If the string is not well-formed, the function returns Rect::ZERO.
|
||||
*/
|
||||
Rect CC_DLL RectFromString(const char* pszContent);
|
||||
|
||||
|
@ -54,7 +54,7 @@ Rect CC_DLL RectFromString(const char* pszContent);
|
|||
An example of a valid string is "{3.0,2.5}".
|
||||
The string is not localized, so items are always separated with a comma.
|
||||
@return A Core Graphics structure that represents a point.
|
||||
If the string is not well-formed, the function returns PointZero.
|
||||
If the string is not well-formed, the function returns Point::ZERO.
|
||||
*/
|
||||
Point CC_DLL PointFromString(const char* pszContent);
|
||||
|
||||
|
@ -66,7 +66,7 @@ Point CC_DLL PointFromString(const char* pszContent);
|
|||
An example of a valid string is "{3.0,2.5}".
|
||||
The string is not localized, so items are always separated with a comma.
|
||||
@return A Core Graphics structure that represents a size.
|
||||
If the string is not well-formed, the function returns SizeZero.
|
||||
If the string is not well-formed, the function returns Size::ZERO.
|
||||
*/
|
||||
Size CC_DLL SizeFromString(const char* pszContent);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -74,7 +74,7 @@ static inline Vertex2F v2fforangle(float _a_)
|
|||
|
||||
static inline Vertex2F v2fnormalize(const Vertex2F &p)
|
||||
{
|
||||
Point r = ccpNormalize(ccp(p.x, p.y));
|
||||
Point r = Point(p.x, p.y).normalize();
|
||||
return v2f(r.x, r.y);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
@ -220,19 +220,19 @@ void ccDrawLine( const Point& origin, const Point& destination )
|
|||
|
||||
void ccDrawRect( Point origin, Point destination )
|
||||
{
|
||||
ccDrawLine(CCPointMake(origin.x, origin.y), CCPointMake(destination.x, origin.y));
|
||||
ccDrawLine(CCPointMake(destination.x, origin.y), CCPointMake(destination.x, destination.y));
|
||||
ccDrawLine(CCPointMake(destination.x, destination.y), CCPointMake(origin.x, destination.y));
|
||||
ccDrawLine(CCPointMake(origin.x, destination.y), CCPointMake(origin.x, origin.y));
|
||||
ccDrawLine(Point(origin.x, origin.y), Point(destination.x, origin.y));
|
||||
ccDrawLine(Point(destination.x, origin.y), Point(destination.x, destination.y));
|
||||
ccDrawLine(Point(destination.x, destination.y), Point(origin.x, destination.y));
|
||||
ccDrawLine(Point(origin.x, destination.y), Point(origin.x, origin.y));
|
||||
}
|
||||
|
||||
void ccDrawSolidRect( Point origin, Point destination, Color4F color )
|
||||
{
|
||||
Point vertices[] = {
|
||||
origin,
|
||||
ccp(destination.x, origin.y),
|
||||
Point(destination.x, origin.y),
|
||||
destination,
|
||||
ccp(origin.x, destination.y)
|
||||
Point(origin.x, destination.y)
|
||||
};
|
||||
|
||||
ccDrawSolidPoly(vertices, 4, color );
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,7 @@ void Grid3D::calculateVertexPoints(void)
|
|||
Vertex3F l2[4] = {e, f, g, h};
|
||||
|
||||
int tex1[4] = {a*2, b*2, c*2, d*2};
|
||||
Point Tex2F[4] = {ccp(x1, y1), ccp(x2, y1), ccp(x2, y2), ccp(x1, y2)};
|
||||
Point Tex2F[4] = {Point(x1, y1), Point(x2, y1), Point(x2, y2), Point(x1, y2)};
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
|
|
|
@ -108,7 +108,7 @@ To enabled set it to 1. Disabled by default.
|
|||
Default: 0,0 (bottom-left corner)
|
||||
*/
|
||||
#ifndef CC_DIRECTOR_FPS_POSITION
|
||||
#define CC_DIRECTOR_FPS_POSITION ccp(0,0)
|
||||
#define CC_DIRECTOR_FPS_POSITION Point(0,0)
|
||||
#endif
|
||||
|
||||
/** @def CC_DIRECTOR_DISPATCH_FAST_EVENTS
|
||||
|
|
|
@ -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 **/
|
||||
|
@ -130,39 +130,39 @@ On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1
|
|||
Converts a rect in pixels to points
|
||||
*/
|
||||
#define CC_RECT_PIXELS_TO_POINTS(__rect_in_pixels__) \
|
||||
CCRectMake( (__rect_in_pixels__).origin.x / CC_CONTENT_SCALE_FACTOR(), (__rect_in_pixels__).origin.y / CC_CONTENT_SCALE_FACTOR(), \
|
||||
Rect( (__rect_in_pixels__).origin.x / CC_CONTENT_SCALE_FACTOR(), (__rect_in_pixels__).origin.y / CC_CONTENT_SCALE_FACTOR(), \
|
||||
(__rect_in_pixels__).size.width / CC_CONTENT_SCALE_FACTOR(), (__rect_in_pixels__).size.height / CC_CONTENT_SCALE_FACTOR() )
|
||||
|
||||
/** @def CC_RECT_POINTS_TO_PIXELS
|
||||
Converts a rect in points to pixels
|
||||
*/
|
||||
#define CC_RECT_POINTS_TO_PIXELS(__rect_in_points_points__) \
|
||||
CCRectMake( (__rect_in_points_points__).origin.x * CC_CONTENT_SCALE_FACTOR(), (__rect_in_points_points__).origin.y * CC_CONTENT_SCALE_FACTOR(), \
|
||||
Rect( (__rect_in_points_points__).origin.x * CC_CONTENT_SCALE_FACTOR(), (__rect_in_points_points__).origin.y * CC_CONTENT_SCALE_FACTOR(), \
|
||||
(__rect_in_points_points__).size.width * CC_CONTENT_SCALE_FACTOR(), (__rect_in_points_points__).size.height * CC_CONTENT_SCALE_FACTOR() )
|
||||
|
||||
/** @def CC_POINT_PIXELS_TO_POINTS
|
||||
Converts a rect in pixels to points
|
||||
*/
|
||||
#define CC_POINT_PIXELS_TO_POINTS(__pixels__) \
|
||||
CCPointMake( (__pixels__).x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).y / CC_CONTENT_SCALE_FACTOR())
|
||||
Point( (__pixels__).x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).y / CC_CONTENT_SCALE_FACTOR())
|
||||
|
||||
/** @def CC_POINT_POINTS_TO_PIXELS
|
||||
Converts a rect in points to pixels
|
||||
*/
|
||||
#define CC_POINT_POINTS_TO_PIXELS(__points__) \
|
||||
CCPointMake( (__points__).x * CC_CONTENT_SCALE_FACTOR(), (__points__).y * CC_CONTENT_SCALE_FACTOR())
|
||||
Point( (__points__).x * CC_CONTENT_SCALE_FACTOR(), (__points__).y * CC_CONTENT_SCALE_FACTOR())
|
||||
|
||||
/** @def CC_POINT_PIXELS_TO_POINTS
|
||||
Converts a rect in pixels to points
|
||||
*/
|
||||
#define CC_SIZE_PIXELS_TO_POINTS(__size_in_pixels__) \
|
||||
CCSizeMake( (__size_in_pixels__).width / CC_CONTENT_SCALE_FACTOR(), (__size_in_pixels__).height / CC_CONTENT_SCALE_FACTOR())
|
||||
Size( (__size_in_pixels__).width / CC_CONTENT_SCALE_FACTOR(), (__size_in_pixels__).height / CC_CONTENT_SCALE_FACTOR())
|
||||
|
||||
/** @def CC_POINT_POINTS_TO_PIXELS
|
||||
Converts a rect in points to pixels
|
||||
*/
|
||||
#define CC_SIZE_POINTS_TO_PIXELS(__size_in_points__) \
|
||||
CCSizeMake( (__size_in_points__).width * CC_CONTENT_SCALE_FACTOR(), (__size_in_points__).height * CC_CONTENT_SCALE_FACTOR())
|
||||
Size( (__size_in_points__).width * CC_CONTENT_SCALE_FACTOR(), (__size_in_points__).height * CC_CONTENT_SCALE_FACTOR())
|
||||
|
||||
|
||||
#ifndef FLT_EPSILON
|
||||
|
@ -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__)
|
||||
|
|
|
@ -401,7 +401,7 @@ public:
|
|||
_alignment(kTextAlignmentCenter),
|
||||
_vertAlignment(kVerticalTextAlignmentTop),
|
||||
_fontFillColor(Color3B::WHITE)
|
||||
{ _dimensions = CCSizeMake(0,0); }
|
||||
{ _dimensions = Size(0,0); }
|
||||
|
||||
// font name
|
||||
std::string _fontName;
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
@ -198,7 +198,7 @@ void LabelAtlas::setString(const char *label)
|
|||
_string = label;
|
||||
this->updateAtlasValues();
|
||||
|
||||
Size s = CCSizeMake(len * _itemWidth, _itemHeight);
|
||||
Size s = Size(len * _itemWidth, _itemHeight);
|
||||
|
||||
this->setContentSize(s);
|
||||
|
||||
|
@ -219,8 +219,8 @@ void LabelAtlas::draw()
|
|||
|
||||
const Size& s = this->getContentSize();
|
||||
Point vertices[4]={
|
||||
ccp(0,0),ccp(s.width,0),
|
||||
ccp(s.width,s.height),ccp(0,s.height),
|
||||
Point(0,0),Point(s.width,0),
|
||||
Point(s.width,s.height),Point(0,s.height),
|
||||
};
|
||||
ccDrawPoly(vertices, 4, true);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -434,21 +434,21 @@ LabelBMFont * LabelBMFont::create()
|
|||
|
||||
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width, TextAlignment alignment)
|
||||
{
|
||||
return LabelBMFont::create(str, fntFile, width, alignment, PointZero);
|
||||
return LabelBMFont::create(str, fntFile, width, alignment, Point::ZERO);
|
||||
}
|
||||
|
||||
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width)
|
||||
{
|
||||
return LabelBMFont::create(str, fntFile, width, kTextAlignmentLeft, PointZero);
|
||||
return LabelBMFont::create(str, fntFile, width, kTextAlignmentLeft, Point::ZERO);
|
||||
}
|
||||
|
||||
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile)
|
||||
{
|
||||
return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, kTextAlignmentLeft, PointZero);
|
||||
return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO);
|
||||
}
|
||||
|
||||
//LabelBMFont - Creation & Init
|
||||
LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextAlignment alignment/* = kTextAlignmentLeft*/, Point imageOffset/* = PointZero*/)
|
||||
LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextAlignment alignment/* = kTextAlignmentLeft*/, Point imageOffset/* = Point::ZERO*/)
|
||||
{
|
||||
LabelBMFont *pRet = new LabelBMFont();
|
||||
if(pRet && pRet->initWithString(str, fntFile, width, alignment, imageOffset))
|
||||
|
@ -462,10 +462,10 @@ LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float wid
|
|||
|
||||
bool LabelBMFont::init()
|
||||
{
|
||||
return initWithString(NULL, NULL, kLabelAutomaticWidth, kTextAlignmentLeft, PointZero);
|
||||
return initWithString(NULL, NULL, kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO);
|
||||
}
|
||||
|
||||
bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextAlignment alignment/* = kTextAlignmentLeft*/, Point imageOffset/* = PointZero*/)
|
||||
bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextAlignment alignment/* = kTextAlignmentLeft*/, Point imageOffset/* = Point::ZERO*/)
|
||||
{
|
||||
CCAssert(!_configuration, "re-init is no longer supported");
|
||||
CCAssert( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for LabelBMFont");
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -511,15 +511,15 @@ bool LabelBMFont::initWithString(const char *theString, const char *fntFile, flo
|
|||
_cascadeOpacityEnabled = true;
|
||||
_cascadeColorEnabled = true;
|
||||
|
||||
_contentSize = SizeZero;
|
||||
_contentSize = Size::ZERO;
|
||||
|
||||
_isOpacityModifyRGB = _textureAtlas->getTexture()->hasPremultipliedAlpha();
|
||||
_anchorPoint = ccp(0.5f, 0.5f);
|
||||
_anchorPoint = Point(0.5f, 0.5f);
|
||||
|
||||
_imageOffset = imageOffset;
|
||||
|
||||
_reusedChar = new Sprite();
|
||||
_reusedChar->initWithTexture(_textureAtlas->getTexture(), CCRectMake(0, 0, 0, 0), false);
|
||||
_reusedChar->initWithTexture(_textureAtlas->getTexture(), Rect(0, 0, 0, 0), false);
|
||||
_reusedChar->setBatchNode(this);
|
||||
|
||||
this->setString(theString, true);
|
||||
|
@ -536,7 +536,7 @@ LabelBMFont::LabelBMFont()
|
|||
, _width(-1.0f)
|
||||
, _configuration(NULL)
|
||||
, _lineBreakWithoutSpaces(false)
|
||||
, _imageOffset(PointZero)
|
||||
, _imageOffset(Point::ZERO)
|
||||
, _reusedChar(NULL)
|
||||
, _displayedOpacity(255)
|
||||
, _realOpacity(255)
|
||||
|
@ -579,7 +579,7 @@ void LabelBMFont::createFontChars()
|
|||
unsigned short prev = -1;
|
||||
int kerningAmount = 0;
|
||||
|
||||
Size tmpSize = SizeZero;
|
||||
Size tmpSize = Size::ZERO;
|
||||
|
||||
int longestLine = 0;
|
||||
unsigned int totalHeight = 0;
|
||||
|
@ -689,7 +689,7 @@ void LabelBMFont::createFontChars()
|
|||
|
||||
// See issue 1343. cast( signed short + unsigned integer ) == unsigned integer (sign is lost!)
|
||||
int yOffset = _configuration->_commonHeight - fontDef.yOffset;
|
||||
Point fontPos = ccp( (float)nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width*0.5f + kerningAmount,
|
||||
Point fontPos = Point( (float)nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width*0.5f + kerningAmount,
|
||||
(float)nextFontPositionY + yOffset - rect.size.height*0.5f * CC_CONTENT_SCALE_FACTOR() );
|
||||
fontChar->setPosition(CC_POINT_PIXELS_TO_POINTS(fontPos));
|
||||
|
||||
|
@ -1145,7 +1145,7 @@ void LabelBMFont::updateLabel()
|
|||
if (index < 0) continue;
|
||||
|
||||
Sprite* characterSprite = static_cast<Sprite*>( getChildByTag(index) );
|
||||
characterSprite->setPosition(ccpAdd(characterSprite->getPosition(), ccp(shift, 0.0f)));
|
||||
characterSprite->setPosition(characterSprite->getPosition() + Point(shift, 0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -1241,8 +1241,8 @@ void LabelBMFont::draw()
|
|||
SpriteBatchNode::draw();
|
||||
const Size& s = this->getContentSize();
|
||||
Point vertices[4]={
|
||||
ccp(0,0),ccp(s.width,0),
|
||||
ccp(s.width,s.height),ccp(0,s.height),
|
||||
Point(0,0),Point(s.width,0),
|
||||
Point(s.width,s.height),Point(0,s.height),
|
||||
};
|
||||
ccDrawPoly(vertices, 4, true);
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ public:
|
|||
|
||||
bool init();
|
||||
/** init a bitmap font atlas with an initial string and the FNT file */
|
||||
bool initWithString(const char *str, const char *fntFile, float width = kLabelAutomaticWidth, TextAlignment alignment = kTextAlignmentLeft, Point imageOffset = PointZero);
|
||||
bool initWithString(const char *str, const char *fntFile, float width = kLabelAutomaticWidth, TextAlignment alignment = kTextAlignmentLeft, Point imageOffset = Point::ZERO);
|
||||
|
||||
/** updates the font chars based on the string to render */
|
||||
void createFontChars();
|
||||
|
|
|
@ -73,7 +73,7 @@ LabelTTF * LabelTTF::create()
|
|||
LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize)
|
||||
{
|
||||
return LabelTTF::create(string, fontName, fontSize,
|
||||
SizeZero, kTextAlignmentCenter, kVerticalTextAlignmentTop);
|
||||
Size::ZERO, kTextAlignmentCenter, kVerticalTextAlignmentTop);
|
||||
}
|
||||
|
||||
LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize,
|
||||
|
@ -122,7 +122,7 @@ bool LabelTTF::initWithString(const char *label, const char *fontName, float fon
|
|||
bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize)
|
||||
{
|
||||
return this->initWithString(label, fontName, fontSize,
|
||||
SizeZero, kTextAlignmentLeft, kVerticalTextAlignmentTop);
|
||||
Size::ZERO, kTextAlignmentLeft, kVerticalTextAlignmentTop);
|
||||
}
|
||||
|
||||
bool LabelTTF::initWithString(const char *string, const char *fontName, float fontSize,
|
||||
|
@ -132,9 +132,9 @@ 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);
|
||||
_dimensions = Size(dimensions.width, dimensions.height);
|
||||
_alignment = hAlignment;
|
||||
_vAlignment = vAlignment;
|
||||
_fontName = new std::string(fontName);
|
||||
|
@ -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);
|
||||
|
@ -320,7 +320,7 @@ bool LabelTTF::updateTexture()
|
|||
tex->release();
|
||||
|
||||
// set the size in the sprite
|
||||
Rect rect =RectZero;
|
||||
Rect rect =Rect::ZERO;
|
||||
rect.size = _texture->getContentSize();
|
||||
this->setTextureRect(rect);
|
||||
|
||||
|
@ -470,7 +470,7 @@ FontDefinition LabelTTF::getTextDefinition()
|
|||
|
||||
void LabelTTF::_updateWithTextDefinition(const FontDefinition& textDefinition, bool mustUpdateTexture)
|
||||
{
|
||||
_dimensions = CCSizeMake(textDefinition._dimensions.width, textDefinition._dimensions.height);
|
||||
_dimensions = Size(textDefinition._dimensions.width, textDefinition._dimensions.height);
|
||||
_alignment = textDefinition._alignment;
|
||||
_vAlignment = textDefinition._vertAlignment;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ Layer::Layer()
|
|||
, _touchMode(kTouchesAllAtOnce)
|
||||
{
|
||||
_ignoreAnchorPointForPosition = true;
|
||||
setAnchorPoint(ccp(0.5f, 0.5f));
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
Layer::~Layer()
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -783,9 +783,9 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h)
|
|||
}
|
||||
|
||||
updateColor();
|
||||
setContentSize(CCSizeMake(w, h));
|
||||
setContentSize(Size(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;
|
||||
}
|
||||
|
@ -811,17 +811,17 @@ void LayerColor::setContentSize(const Size & size)
|
|||
|
||||
void LayerColor::changeWidthAndHeight(GLfloat w ,GLfloat h)
|
||||
{
|
||||
this->setContentSize(CCSizeMake(w, h));
|
||||
this->setContentSize(Size(w, h));
|
||||
}
|
||||
|
||||
void LayerColor::changeWidth(GLfloat w)
|
||||
{
|
||||
this->setContentSize(CCSizeMake(w, _contentSize.height));
|
||||
this->setContentSize(Size(w, _contentSize.height));
|
||||
}
|
||||
|
||||
void LayerColor::changeHeight(GLfloat h)
|
||||
{
|
||||
this->setContentSize(CCSizeMake(_contentSize.width, h));
|
||||
this->setContentSize(Size(_contentSize.width, h));
|
||||
}
|
||||
|
||||
void LayerColor::updateColor()
|
||||
|
@ -922,7 +922,7 @@ bool LayerGradient::init()
|
|||
|
||||
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end)
|
||||
{
|
||||
return initWithColor(start, end, ccp(0, -1));
|
||||
return initWithColor(start, end, Point(0, -1));
|
||||
}
|
||||
|
||||
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, const Point& v)
|
||||
|
@ -944,18 +944,18 @@ void LayerGradient::updateColor()
|
|||
{
|
||||
LayerColor::updateColor();
|
||||
|
||||
float h = ccpLength(_alongVector);
|
||||
float h = _alongVector.getLength();
|
||||
if (h == 0)
|
||||
return;
|
||||
|
||||
float c = sqrtf(2.0f);
|
||||
Point u = ccp(_alongVector.x / h, _alongVector.y / h);
|
||||
Point u = Point(_alongVector.x / h, _alongVector.y / h);
|
||||
|
||||
// Compressed Interpolation mode
|
||||
if (_compressedInterpolation)
|
||||
{
|
||||
float h2 = 1 / ( fabsf(u.x) + fabsf(u.y) );
|
||||
u = ccpMult(u, h2 * (float)c);
|
||||
u = u * (h2 * (float)c);
|
||||
}
|
||||
|
||||
float opacityf = (float)_displayedOpacity / 255.0f;
|
||||
|
|
|
@ -33,7 +33,7 @@ NS_CC_BEGIN
|
|||
Scene::Scene()
|
||||
{
|
||||
_ignoreAnchorPointForPosition = true;
|
||||
setAnchorPoint(ccp(0.5f, 0.5f));
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
@ -117,13 +117,13 @@ void TransitionScene::finish()
|
|||
{
|
||||
// clean up
|
||||
_inScene->setVisible(true);
|
||||
_inScene->setPosition(ccp(0,0));
|
||||
_inScene->setPosition(Point(0,0));
|
||||
_inScene->setScale(1.0f);
|
||||
_inScene->setRotation(0.0f);
|
||||
_inScene->getCamera()->restore();
|
||||
|
||||
_outScene->setVisible(false);
|
||||
_outScene->setPosition(ccp(0,0));
|
||||
_outScene->setPosition(Point(0,0));
|
||||
_outScene->setScale(1.0f);
|
||||
_outScene->setRotation(0.0f);
|
||||
_outScene->getCamera()->restore();
|
||||
|
@ -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();
|
||||
|
||||
|
@ -254,8 +254,8 @@ void TransitionRotoZoom:: onEnter()
|
|||
_inScene->setScale(0.001f);
|
||||
_outScene->setScale(1.0f);
|
||||
|
||||
_inScene->setAnchorPoint(ccp(0.5f, 0.5f));
|
||||
_outScene->setAnchorPoint(ccp(0.5f, 0.5f));
|
||||
_inScene->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
_outScene->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
|
||||
ActionInterval *rotozoom = (ActionInterval*)(Sequence::create
|
||||
(
|
||||
|
@ -306,14 +306,14 @@ 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));
|
||||
_inScene->setAnchorPoint(ccp(0.5f, 0.5f));
|
||||
_outScene->setAnchorPoint(ccp(0.5f, 0.5f));
|
||||
_inScene->setPosition(Point(s.width, 0));
|
||||
_inScene->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
_outScene->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
|
||||
ActionInterval *jump = JumpBy::create(_duration/4, ccp(-s.width,0), s.width/4, 2);
|
||||
ActionInterval *jump = JumpBy::create(_duration/4, Point(-s.width,0), s.width/4, 2);
|
||||
ActionInterval *scaleIn = ScaleTo::create(_duration/4, 1.0f);
|
||||
ActionInterval *scaleOut = ScaleTo::create(_duration/4, 0.5f);
|
||||
|
||||
|
@ -378,7 +378,7 @@ void TransitionMoveInL::onEnter()
|
|||
|
||||
ActionInterval* TransitionMoveInL::action()
|
||||
{
|
||||
return MoveTo::create(_duration, ccp(0,0));
|
||||
return MoveTo::create(_duration, Point(0,0));
|
||||
}
|
||||
|
||||
ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action)
|
||||
|
@ -389,8 +389,8 @@ ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action)
|
|||
|
||||
void TransitionMoveInL::initScenes()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
_inScene->setPosition(ccp(-s.width,0));
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition(Point(-s.width,0));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -417,8 +417,8 @@ TransitionMoveInR* TransitionMoveInR::create(float t, Scene* scene)
|
|||
|
||||
void TransitionMoveInR::initScenes()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
_inScene->setPosition( ccp(s.width,0) );
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(s.width,0) );
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -445,8 +445,8 @@ TransitionMoveInT* TransitionMoveInT::create(float t, Scene* scene)
|
|||
|
||||
void TransitionMoveInT::initScenes()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
_inScene->setPosition( ccp(0,s.height) );
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(0,s.height) );
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -473,8 +473,8 @@ TransitionMoveInB* TransitionMoveInB::create(float t, Scene* scene)
|
|||
|
||||
void TransitionMoveInB::initScenes()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
_inScene->setPosition( ccp(0,-s.height) );
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(0,-s.height) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -521,14 +521,14 @@ void TransitionSlideInL::sceneOrder()
|
|||
|
||||
void TransitionSlideInL:: initScenes()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
_inScene->setPosition( ccp(-(s.width-ADJUST_FACTOR),0) );
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(-(s.width-ADJUST_FACTOR),0) );
|
||||
}
|
||||
|
||||
ActionInterval* TransitionSlideInL::action()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
return MoveBy::create(_duration, ccp(s.width-ADJUST_FACTOR,0));
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
return MoveBy::create(_duration, Point(s.width-ADJUST_FACTOR,0));
|
||||
}
|
||||
|
||||
ActionInterval* TransitionSlideInL::easeActionWithAction(ActionInterval* action)
|
||||
|
@ -577,15 +577,15 @@ void TransitionSlideInR::sceneOrder()
|
|||
|
||||
void TransitionSlideInR::initScenes()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
_inScene->setPosition( ccp(s.width-ADJUST_FACTOR,0) );
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(s.width-ADJUST_FACTOR,0) );
|
||||
}
|
||||
|
||||
|
||||
ActionInterval* TransitionSlideInR:: action()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
return MoveBy::create(_duration, ccp(-(s.width-ADJUST_FACTOR),0));
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
return MoveBy::create(_duration, Point(-(s.width-ADJUST_FACTOR),0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -618,15 +618,15 @@ void TransitionSlideInT::sceneOrder()
|
|||
|
||||
void TransitionSlideInT::initScenes()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
_inScene->setPosition( ccp(0,s.height-ADJUST_FACTOR) );
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(0,s.height-ADJUST_FACTOR) );
|
||||
}
|
||||
|
||||
|
||||
ActionInterval* TransitionSlideInT::action()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
return MoveBy::create(_duration, ccp(0,-(s.height-ADJUST_FACTOR)));
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
return MoveBy::create(_duration, Point(0,-(s.height-ADJUST_FACTOR)));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -658,15 +658,15 @@ void TransitionSlideInB::sceneOrder()
|
|||
|
||||
void TransitionSlideInB:: initScenes()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
_inScene->setPosition( ccp(0,-(s.height-ADJUST_FACTOR)) );
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
_inScene->setPosition( Point(0,-(s.height-ADJUST_FACTOR)) );
|
||||
}
|
||||
|
||||
|
||||
ActionInterval* TransitionSlideInB:: action()
|
||||
{
|
||||
Size s = Director::sharedDirector()->getWinSize();
|
||||
return MoveBy::create(_duration, ccp(0,s.height-ADJUST_FACTOR));
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
return MoveBy::create(_duration, Point(0,s.height-ADJUST_FACTOR));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -698,8 +698,8 @@ void TransitionShrinkGrow::onEnter()
|
|||
_inScene->setScale(0.001f);
|
||||
_outScene->setScale(1.0f);
|
||||
|
||||
_inScene->setAnchorPoint(ccp(2/3.0f,0.5f));
|
||||
_outScene->setAnchorPoint(ccp(1/3.0f,0.5f));
|
||||
_inScene->setAnchorPoint(Point(2/3.0f,0.5f));
|
||||
_outScene->setAnchorPoint(Point(1/3.0f,0.5f));
|
||||
|
||||
ActionInterval* scaleOut = ScaleTo::create(_duration, 0.01f);
|
||||
ActionInterval* scaleIn = ScaleTo::create(_duration, 1.0f);
|
||||
|
@ -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
|
||||
|
@ -1282,9 +1282,9 @@ void TransitionCrossFade::onEnter()
|
|||
return;
|
||||
}
|
||||
|
||||
inTexture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) );
|
||||
inTexture->setPosition( ccp(size.width/2, size.height/2) );
|
||||
inTexture->setAnchorPoint( ccp(0.5f,0.5f) );
|
||||
inTexture->getSprite()->setAnchorPoint( Point(0.5f,0.5f) );
|
||||
inTexture->setPosition( Point(size.width/2, size.height/2) );
|
||||
inTexture->setAnchorPoint( Point(0.5f,0.5f) );
|
||||
|
||||
// render inScene to its texturebuffer
|
||||
inTexture->begin();
|
||||
|
@ -1293,9 +1293,9 @@ void TransitionCrossFade::onEnter()
|
|||
|
||||
// create the second render texture for outScene
|
||||
RenderTexture* outTexture = RenderTexture::create((int)size.width, (int)size.height);
|
||||
outTexture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) );
|
||||
outTexture->setPosition( ccp(size.width/2, size.height/2) );
|
||||
outTexture->setAnchorPoint( ccp(0.5f,0.5f) );
|
||||
outTexture->getSprite()->setAnchorPoint( Point(0.5f,0.5f) );
|
||||
outTexture->setPosition( Point(size.width/2, size.height/2) );
|
||||
outTexture->setAnchorPoint( Point(0.5f,0.5f) );
|
||||
|
||||
// render outScene to its texturebuffer
|
||||
outTexture->begin();
|
||||
|
@ -1376,12 +1376,12 @@ 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;
|
||||
|
||||
TurnOffTiles* toff = TurnOffTiles::create(_duration, CCSizeMake(x,y));
|
||||
TurnOffTiles* toff = TurnOffTiles::create(_duration, Size(x,y));
|
||||
ActionInterval* action = easeActionWithAction(toff);
|
||||
_outScene->runAction
|
||||
(
|
||||
|
@ -1520,12 +1520,12 @@ 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;
|
||||
|
||||
ActionInterval* action = actionWithSize(CCSizeMake(x,y));
|
||||
ActionInterval* action = actionWithSize(Size(x,y));
|
||||
|
||||
_outScene->runAction
|
||||
(
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ void TransitionPageTurn::onEnter()
|
|||
y=16;
|
||||
}
|
||||
|
||||
ActionInterval *action = this->actionWithSize(CCSizeMake(x,y));
|
||||
ActionInterval *action = this->actionWithSize(Size(x,y));
|
||||
|
||||
if (! _back )
|
||||
{
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -69,13 +69,13 @@ 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);
|
||||
texture->getSprite()->setAnchorPoint(ccp(0.5f,0.5f));
|
||||
texture->setPosition(ccp(size.width/2, size.height/2));
|
||||
texture->setAnchorPoint(ccp(0.5f,0.5f));
|
||||
texture->getSprite()->setAnchorPoint(Point(0.5f,0.5f));
|
||||
texture->setPosition(Point(size.width/2, size.height/2));
|
||||
texture->setAnchorPoint(Point(0.5f,0.5f));
|
||||
|
||||
// render outScene to its texturebuffer
|
||||
texture->clear(0, 0, 0, 1);
|
||||
|
@ -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());
|
||||
|
||||
|
@ -146,8 +146,8 @@ ProgressTimer* TransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(R
|
|||
// Return the radial type that we want to use
|
||||
pNode->setReverseDirection(false);
|
||||
pNode->setPercentage(100);
|
||||
pNode->setPosition(ccp(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(ccp(0.5f,0.5f));
|
||||
pNode->setPosition(Point(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(Point(0.5f,0.5f));
|
||||
|
||||
return pNode;
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
|
@ -190,8 +190,8 @@ ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(Re
|
|||
// Return the radial type that we want to use
|
||||
pNode->setReverseDirection(true);
|
||||
pNode->setPercentage(100);
|
||||
pNode->setPosition(ccp(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(ccp(0.5f,0.5f));
|
||||
pNode->setPosition(Point(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(Point(0.5f,0.5f));
|
||||
|
||||
return pNode;
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
|
@ -219,12 +219,12 @@ ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture(
|
|||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType( kProgressTimerTypeBar);
|
||||
|
||||
pNode->setMidpoint(ccp(1, 0));
|
||||
pNode->setBarChangeRate(ccp(1,0));
|
||||
pNode->setMidpoint(Point(1, 0));
|
||||
pNode->setBarChangeRate(Point(1,0));
|
||||
|
||||
pNode->setPercentage(100);
|
||||
pNode->setPosition(ccp(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(ccp(0.5f,0.5f));
|
||||
pNode->setPosition(Point(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(Point(0.5f,0.5f));
|
||||
|
||||
return pNode;
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
|
@ -252,12 +252,12 @@ ProgressTimer* TransitionProgressVertical::progressTimerNodeWithRenderTexture(Re
|
|||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType(kProgressTimerTypeBar);
|
||||
|
||||
pNode->setMidpoint(ccp(0, 0));
|
||||
pNode->setBarChangeRate(ccp(0,1));
|
||||
pNode->setMidpoint(Point(0, 0));
|
||||
pNode->setBarChangeRate(Point(0,1));
|
||||
|
||||
pNode->setPercentage(100);
|
||||
pNode->setPosition(ccp(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(ccp(0.5f,0.5f));
|
||||
pNode->setPosition(Point(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(Point(0.5f,0.5f));
|
||||
|
||||
return pNode;
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
|
@ -298,12 +298,12 @@ ProgressTimer* TransitionProgressInOut::progressTimerNodeWithRenderTexture(Rende
|
|||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType( kProgressTimerTypeBar);
|
||||
|
||||
pNode->setMidpoint(ccp(0.5f, 0.5f));
|
||||
pNode->setBarChangeRate(ccp(1, 1));
|
||||
pNode->setMidpoint(Point(0.5f, 0.5f));
|
||||
pNode->setBarChangeRate(Point(1, 1));
|
||||
|
||||
pNode->setPercentage(0);
|
||||
pNode->setPosition(ccp(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(ccp(0.5f,0.5f));
|
||||
pNode->setPosition(Point(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(Point(0.5f,0.5f));
|
||||
|
||||
return pNode;
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
|
@ -332,12 +332,12 @@ ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(Rende
|
|||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType( kProgressTimerTypeBar );
|
||||
|
||||
pNode->setMidpoint(ccp(0.5f, 0.5f));
|
||||
pNode->setBarChangeRate(ccp(1, 1));
|
||||
pNode->setMidpoint(Point(0.5f, 0.5f));
|
||||
pNode->setBarChangeRate(Point(1, 1));
|
||||
|
||||
pNode->setPercentage(100);
|
||||
pNode->setPosition(ccp(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(ccp(0.5f,0.5f));
|
||||
pNode->setPosition(Point(size.width/2, size.height/2));
|
||||
pNode->setAnchorPoint(Point(0.5f,0.5f));
|
||||
|
||||
return pNode;
|
||||
}
|
||||
|
|
|
@ -128,13 +128,13 @@ 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));
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
this->setContentSize(s);
|
||||
|
||||
setPosition(ccp(s.width/2, s.height/2));
|
||||
setPosition(Point(s.width/2, s.height/2));
|
||||
|
||||
if (pArrayOfItems != NULL)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ void Menu::alignItemsVerticallyWithPadding(float padding)
|
|||
Node* pChild = dynamic_cast<Node*>(pObject);
|
||||
if (pChild)
|
||||
{
|
||||
pChild->setPosition(ccp(0, y - pChild->getContentSize().height * pChild->getScaleY() / 2.0f));
|
||||
pChild->setPosition(Point(0, y - pChild->getContentSize().height * pChild->getScaleY() / 2.0f));
|
||||
y -= pChild->getContentSize().height * pChild->getScaleY() + padding;
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ void Menu::alignItemsHorizontallyWithPadding(float padding)
|
|||
Node* pChild = dynamic_cast<Node*>(pObject);
|
||||
if (pChild)
|
||||
{
|
||||
pChild->setPosition(ccp(x + pChild->getContentSize().width * pChild->getScaleX() / 2.0f, 0));
|
||||
pChild->setPosition(Point(x + pChild->getContentSize().width * pChild->getScaleX() / 2.0f, 0));
|
||||
x += pChild->getContentSize().width * pChild->getScaleX() + padding;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -460,7 +460,7 @@ void Menu::alignItemsInColumnsWithArray(Array* rowsArray)
|
|||
float tmp = pChild->getContentSize().height;
|
||||
rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp);
|
||||
|
||||
pChild->setPosition(ccp(x - winSize.width / 2,
|
||||
pChild->setPosition(Point(x - winSize.width / 2,
|
||||
y - pChild->getContentSize().height / 2));
|
||||
|
||||
x += w;
|
||||
|
@ -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;
|
||||
|
@ -581,7 +581,7 @@ void Menu::alignItemsInRowsWithArray(Array* columnArray)
|
|||
float tmp = pChild->getContentSize().width;
|
||||
columnWidth = (unsigned int)((columnWidth >= tmp || isnan(tmp)) ? columnWidth : tmp);
|
||||
|
||||
pChild->setPosition(ccp(x + columnWidths[column] / 2,
|
||||
pChild->setPosition(Point(x + columnWidths[column] / 2,
|
||||
y - winSize.height / 2));
|
||||
|
||||
y -= pChild->getContentSize().height + 10;
|
||||
|
@ -614,7 +614,7 @@ MenuItem* Menu::itemForTouch(Touch *touch)
|
|||
{
|
||||
Point local = pChild->convertToNodeSpace(touchLocation);
|
||||
Rect r = pChild->rect();
|
||||
r.origin = PointZero;
|
||||
r.origin = Point::ZERO;
|
||||
|
||||
if (r.containsPoint(local))
|
||||
{
|
||||
|
|
|
@ -82,7 +82,7 @@ bool MenuItem::initWithTarget(cocos2d::Object *target, SEL_MenuHandler selector
|
|||
|
||||
bool MenuItem::initWithCallback(const ccMenuCallback& callback)
|
||||
{
|
||||
setAnchorPoint(ccp(0.5f, 0.5f));
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
_callback = callback;
|
||||
_enabled = true;
|
||||
_selected = false;
|
||||
|
@ -157,7 +157,7 @@ bool MenuItem::isEnabled() const
|
|||
|
||||
Rect MenuItem::rect()
|
||||
{
|
||||
return CCRectMake( _position.x - _contentSize.width * _anchorPoint.x,
|
||||
return Rect( _position.x - _contentSize.width * _anchorPoint.x,
|
||||
_position.y - _contentSize.height * _anchorPoint.y,
|
||||
_contentSize.width, _contentSize.height);
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ void MenuItemLabel::setLabel(Node* var)
|
|||
if (var)
|
||||
{
|
||||
addChild(var);
|
||||
var->setAnchorPoint(ccp(0, 0));
|
||||
var->setAnchorPoint(Point(0, 0));
|
||||
setContentSize(var->getContentSize());
|
||||
}
|
||||
|
||||
|
@ -509,7 +509,7 @@ void MenuItemSprite::setNormalImage(Node* pImage)
|
|||
if (pImage)
|
||||
{
|
||||
addChild(pImage, 0, kNormalTag);
|
||||
pImage->setAnchorPoint(ccp(0, 0));
|
||||
pImage->setAnchorPoint(Point(0, 0));
|
||||
}
|
||||
|
||||
if (_normalImage)
|
||||
|
@ -535,7 +535,7 @@ void MenuItemSprite::setSelectedImage(Node* pImage)
|
|||
if (pImage)
|
||||
{
|
||||
addChild(pImage, 0, kSelectedTag);
|
||||
pImage->setAnchorPoint(ccp(0, 0));
|
||||
pImage->setAnchorPoint(Point(0, 0));
|
||||
}
|
||||
|
||||
if (_selectedImage)
|
||||
|
@ -560,7 +560,7 @@ void MenuItemSprite::setDisabledImage(Node* pImage)
|
|||
if (pImage)
|
||||
{
|
||||
addChild(pImage, 0, kDisableTag);
|
||||
pImage->setAnchorPoint(ccp(0, 0));
|
||||
pImage->setAnchorPoint(Point(0, 0));
|
||||
}
|
||||
|
||||
if (_disabledImage)
|
||||
|
@ -998,7 +998,7 @@ void MenuItemToggle::setSelectedIndex(unsigned int index)
|
|||
this->addChild(item, 0, kCurrentItem);
|
||||
Size s = item->getContentSize();
|
||||
this->setContentSize(s);
|
||||
item->setPosition( ccp( s.width/2, s.height/2 ) );
|
||||
item->setPosition( Point( s.width/2, s.height/2 ) );
|
||||
}
|
||||
}
|
||||
unsigned int MenuItemToggle::getSelectedIndex()
|
||||
|
|
|
@ -152,7 +152,7 @@ void ClippingNode::drawFullScreenQuadClearStencil()
|
|||
kmGLPushMatrix();
|
||||
kmGLLoadIdentity();
|
||||
|
||||
ccDrawSolidRect(ccp(-1,-1), ccp(1,1), Color4F(1, 1, 1, 1));
|
||||
ccDrawSolidRect(Point(-1,-1), Point(1,1), Color4F(1, 1, 1, 1));
|
||||
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLPopMatrix();
|
||||
|
@ -273,7 +273,7 @@ void ClippingNode::visit()
|
|||
glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
|
||||
|
||||
// draw a fullscreen solid rectangle to clear the stencil buffer
|
||||
//ccDrawSolidRect(PointZero, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
|
||||
//ccDrawSolidRect(Point::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
|
||||
drawFullScreenQuadClearStencil();
|
||||
|
||||
///////////////////////////////////
|
||||
|
@ -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);
|
||||
|
|
|
@ -38,7 +38,7 @@ MotionStreak::MotionStreak()
|
|||
: _fastMode(false)
|
||||
, _startingPositionInitialized(false)
|
||||
, _texture(NULL)
|
||||
, _positionR(PointZero)
|
||||
, _positionR(Point::ZERO)
|
||||
, _stroke(0.0f)
|
||||
, _fadeDelta(0.0f)
|
||||
, _minSeg(0.0f)
|
||||
|
@ -95,18 +95,18 @@ 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);
|
||||
}
|
||||
|
||||
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture)
|
||||
{
|
||||
Node::setPosition(PointZero);
|
||||
setAnchorPoint(PointZero);
|
||||
Node::setPosition(Point::ZERO);
|
||||
setAnchorPoint(Point::ZERO);
|
||||
ignoreAnchorPointForPosition(true);
|
||||
_startingPositionInitialized = false;
|
||||
|
||||
_positionR = PointZero;
|
||||
_positionR = Point::ZERO;
|
||||
_fastMode = true;
|
||||
_minSeg = (minSeg == -1.0f) ? stroke/5.0f : minSeg;
|
||||
_minSeg *= _minSeg;
|
||||
|
@ -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);
|
||||
|
@ -265,8 +265,8 @@ void MotionStreak::update(float delta)
|
|||
|
||||
else if(_nuPoints>0)
|
||||
{
|
||||
bool a1 = ccpDistanceSQ(_pointVertexes[_nuPoints-1], _positionR) < _minSeg;
|
||||
bool a2 = (_nuPoints == 1) ? false : (ccpDistanceSQ(_pointVertexes[_nuPoints-2], _positionR) < (_minSeg * 2.0f));
|
||||
bool a1 = _pointVertexes[_nuPoints-1].getDistanceSq(_positionR) < _minSeg;
|
||||
bool a2 = (_nuPoints == 1) ? false : (_pointVertexes[_nuPoints-2].getDistanceSq(_positionR)< (_minSeg * 2.0f));
|
||||
if(a1 || a2)
|
||||
{
|
||||
appendNewPoint = false;
|
||||
|
|
|
@ -78,14 +78,14 @@ bool ProgressTimer::initWithSprite(Sprite* sp)
|
|||
_vertexData = NULL;
|
||||
_vertexDataCount = 0;
|
||||
|
||||
setAnchorPoint(ccp(0.5f,0.5f));
|
||||
setAnchorPoint(Point(0.5f,0.5f));
|
||||
_type = kProgressTimerTypeRadial;
|
||||
_reverseDirection = false;
|
||||
setMidpoint(ccp(0.5f, 0.5f));
|
||||
setBarChangeRate(ccp(1,1));
|
||||
setMidpoint(Point(0.5f, 0.5f));
|
||||
setBarChangeRate(Point(1,1));
|
||||
setSprite(sp);
|
||||
// shader program
|
||||
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTextureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -171,8 +171,8 @@ Tex2F ProgressTimer::textureCoordFromAlphaPoint(Point alpha)
|
|||
return ret;
|
||||
}
|
||||
V3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
||||
Point min = ccp(quad.bl.texCoords.u,quad.bl.texCoords.v);
|
||||
Point max = ccp(quad.tr.texCoords.u,quad.tr.texCoords.v);
|
||||
Point min = Point(quad.bl.texCoords.u,quad.bl.texCoords.v);
|
||||
Point max = Point(quad.tr.texCoords.u,quad.tr.texCoords.v);
|
||||
// Fix bug #1303 so that progress timer handles sprite frame texture rotation
|
||||
if (_sprite->isTextureRectRotated()) {
|
||||
CC_SWAP(alpha.x, alpha.y, float);
|
||||
|
@ -187,8 +187,8 @@ Vertex2F ProgressTimer::vertexFromAlphaPoint(Point alpha)
|
|||
return ret;
|
||||
}
|
||||
V3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
||||
Point min = ccp(quad.bl.vertices.x,quad.bl.vertices.y);
|
||||
Point max = ccp(quad.tr.vertices.x,quad.tr.vertices.y);
|
||||
Point min = Point(quad.bl.vertices.x,quad.bl.vertices.y);
|
||||
Point max = Point(quad.tr.vertices.x,quad.tr.vertices.y);
|
||||
ret.x = min.x * (1.f - alpha.x) + max.x * alpha.x;
|
||||
ret.y = min.y * (1.f - alpha.y) + max.y * alpha.y;
|
||||
return ret;
|
||||
|
@ -237,7 +237,7 @@ Point ProgressTimer::getMidpoint(void)
|
|||
|
||||
void ProgressTimer::setMidpoint(Point midPoint)
|
||||
{
|
||||
_midpoint = ccpClamp(midPoint, PointZero, ccp(1,1));
|
||||
_midpoint = midPoint.getClampPoint(Point::ZERO, Point(1, 1));
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -261,12 +261,12 @@ void ProgressTimer::updateRadial(void)
|
|||
// We find the vector to do a hit detection based on the percentage
|
||||
// We know the first vector is the one @ 12 o'clock (top,mid) so we rotate
|
||||
// from that by the progress angle around the _midpoint pivot
|
||||
Point topMid = ccp(_midpoint.x, 1.f);
|
||||
Point percentagePt = ccpRotateByAngle(topMid, _midpoint, angle);
|
||||
Point topMid = Point(_midpoint.x, 1.f);
|
||||
Point percentagePt = topMid.rotateByAngle(_midpoint, angle);
|
||||
|
||||
|
||||
int index = 0;
|
||||
Point hit = PointZero;
|
||||
Point hit = Point::ZERO;
|
||||
|
||||
if (alpha == 0.f) {
|
||||
// More efficient since we don't always need to check intersection
|
||||
|
@ -294,14 +294,14 @@ void ProgressTimer::updateRadial(void)
|
|||
// Remember that the top edge is split in half for the 12 o'clock position
|
||||
// Let's deal with that here by finding the correct endpoints
|
||||
if(i == 0){
|
||||
edgePtB = ccpLerp(edgePtA, edgePtB, 1-_midpoint.x);
|
||||
edgePtB = edgePtA.lerp(edgePtB, 1-_midpoint.x);
|
||||
} else if(i == 4){
|
||||
edgePtA = ccpLerp(edgePtA, edgePtB, 1-_midpoint.x);
|
||||
edgePtA = edgePtA.lerp(edgePtB, 1-_midpoint.x);
|
||||
}
|
||||
|
||||
// s and t are returned by ccpLineIntersect
|
||||
float s = 0, t = 0;
|
||||
if(ccpLineIntersect(edgePtA, edgePtB, _midpoint, percentagePt, &s, &t))
|
||||
if(Point::isLineIntersect(edgePtA, edgePtB, _midpoint, percentagePt, &s, &t))
|
||||
{
|
||||
|
||||
// Since our hit test is on rays we have to deal with the top edge
|
||||
|
@ -326,7 +326,7 @@ void ProgressTimer::updateRadial(void)
|
|||
}
|
||||
|
||||
// Now that we have the minimum magnitude we can use that to find our intersection
|
||||
hit = ccpAdd(_midpoint, ccpMult(ccpSub(percentagePt, _midpoint),min_t));
|
||||
hit = _midpoint+ ((percentagePt - _midpoint) * min_t);
|
||||
|
||||
}
|
||||
|
||||
|
@ -387,9 +387,9 @@ void ProgressTimer::updateBar(void)
|
|||
return;
|
||||
}
|
||||
float alpha = _percentage / 100.0f;
|
||||
Point alphaOffset = ccpMult(ccp(1.0f * (1.0f - _barChangeRate.x) + alpha * _barChangeRate.x, 1.0f * (1.0f - _barChangeRate.y) + alpha * _barChangeRate.y), 0.5f);
|
||||
Point min = ccpSub(_midpoint, alphaOffset);
|
||||
Point max = ccpAdd(_midpoint, alphaOffset);
|
||||
Point alphaOffset = Point(1.0f * (1.0f - _barChangeRate.x) + alpha * _barChangeRate.x, 1.0f * (1.0f - _barChangeRate.y) + alpha * _barChangeRate.y) * 0.5f;
|
||||
Point min = _midpoint - alphaOffset;
|
||||
Point max = _midpoint + alphaOffset;
|
||||
|
||||
if (min.x < 0.f) {
|
||||
max.x += -min.x;
|
||||
|
@ -419,57 +419,57 @@ void ProgressTimer::updateBar(void)
|
|||
CCAssert( _vertexData, "CCProgressTimer. Not enough memory");
|
||||
}
|
||||
// TOPLEFT
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(ccp(min.x,max.y));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(ccp(min.x,max.y));
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Point(min.x,max.y));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Point(min.x,max.y));
|
||||
|
||||
// BOTLEFT
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(ccp(min.x,min.y));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(ccp(min.x,min.y));
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Point(min.x,min.y));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Point(min.x,min.y));
|
||||
|
||||
// TOPRIGHT
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(ccp(max.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(ccp(max.x,max.y));
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Point(max.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(Point(max.x,max.y));
|
||||
|
||||
// BOTRIGHT
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(ccp(max.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(ccp(max.x,min.y));
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Point(max.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(Point(max.x,min.y));
|
||||
} else {
|
||||
if(!_vertexData) {
|
||||
_vertexDataCount = 8;
|
||||
_vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F));
|
||||
CCAssert( _vertexData, "CCProgressTimer. Not enough memory");
|
||||
// TOPLEFT 1
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(ccp(0,1));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(ccp(0,1));
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Point(0,1));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Point(0,1));
|
||||
|
||||
// BOTLEFT 1
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(ccp(0,0));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(ccp(0,0));
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Point(0,0));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Point(0,0));
|
||||
|
||||
// TOPRIGHT 2
|
||||
_vertexData[6].texCoords = textureCoordFromAlphaPoint(ccp(1,1));
|
||||
_vertexData[6].vertices = vertexFromAlphaPoint(ccp(1,1));
|
||||
_vertexData[6].texCoords = textureCoordFromAlphaPoint(Point(1,1));
|
||||
_vertexData[6].vertices = vertexFromAlphaPoint(Point(1,1));
|
||||
|
||||
// BOTRIGHT 2
|
||||
_vertexData[7].texCoords = textureCoordFromAlphaPoint(ccp(1,0));
|
||||
_vertexData[7].vertices = vertexFromAlphaPoint(ccp(1,0));
|
||||
_vertexData[7].texCoords = textureCoordFromAlphaPoint(Point(1,0));
|
||||
_vertexData[7].vertices = vertexFromAlphaPoint(Point(1,0));
|
||||
}
|
||||
|
||||
// TOPRIGHT 1
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(ccp(min.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(ccp(min.x,max.y));
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Point(min.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(Point(min.x,max.y));
|
||||
|
||||
// BOTRIGHT 1
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(ccp(min.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(ccp(min.x,min.y));
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Point(min.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(Point(min.x,min.y));
|
||||
|
||||
// TOPLEFT 2
|
||||
_vertexData[4].texCoords = textureCoordFromAlphaPoint(ccp(max.x,max.y));
|
||||
_vertexData[4].vertices = vertexFromAlphaPoint(ccp(max.x,max.y));
|
||||
_vertexData[4].texCoords = textureCoordFromAlphaPoint(Point(max.x,max.y));
|
||||
_vertexData[4].vertices = vertexFromAlphaPoint(Point(max.x,max.y));
|
||||
|
||||
// BOTLEFT 2
|
||||
_vertexData[5].texCoords = textureCoordFromAlphaPoint(ccp(max.x,min.y));
|
||||
_vertexData[5].vertices = vertexFromAlphaPoint(ccp(max.x,min.y));
|
||||
_vertexData[5].texCoords = textureCoordFromAlphaPoint(Point(max.x,min.y));
|
||||
_vertexData[5].vertices = vertexFromAlphaPoint(Point(max.x,min.y));
|
||||
}
|
||||
updateColor();
|
||||
}
|
||||
|
@ -478,12 +478,12 @@ Point ProgressTimer::boundaryTexCoord(char index)
|
|||
{
|
||||
if (index < kProgressTextureCoordsCount) {
|
||||
if (_reverseDirection) {
|
||||
return ccp((kProgressTextureCoords>>(7-(index<<1)))&1,(kProgressTextureCoords>>(7-((index<<1)+1)))&1);
|
||||
return Point((kProgressTextureCoords>>(7-(index<<1)))&1,(kProgressTextureCoords>>(7-((index<<1)+1)))&1);
|
||||
} else {
|
||||
return ccp((kProgressTextureCoords>>((index<<1)+1))&1,(kProgressTextureCoords>>(index<<1))&1);
|
||||
return Point((kProgressTextureCoords>>((index<<1)+1))&1,(kProgressTextureCoords>>(index<<1))&1);
|
||||
}
|
||||
}
|
||||
return PointZero;
|
||||
return Point::ZERO;
|
||||
}
|
||||
|
||||
void ProgressTimer::draw(void)
|
||||
|
|
|
@ -112,10 +112,10 @@ protected:
|
|||
* If you're using radials type then the midpoint changes the center point
|
||||
* If you're using bar type the the midpoint changes the bar growth
|
||||
* it expands from the center but clamps to the sprites edge so:
|
||||
* you want a left to right then set the midpoint all the way to ccp(0,y)
|
||||
* you want a right to left then set the midpoint all the way to ccp(1,y)
|
||||
* you want a bottom to top then set the midpoint all the way to ccp(x,0)
|
||||
* you want a top to bottom then set the midpoint all the way to ccp(x,1)
|
||||
* you want a left to right then set the midpoint all the way to Point(0,y)
|
||||
* you want a right to left then set the midpoint all the way to Point(1,y)
|
||||
* you want a bottom to top then set the midpoint all the way to Point(x,0)
|
||||
* you want a top to bottom then set the midpoint all the way to Point(x,1)
|
||||
*/
|
||||
CC_PROPERTY(Point, _midpoint, Midpoint);
|
||||
|
||||
|
@ -123,7 +123,7 @@ protected:
|
|||
* This allows the bar type to move the component at a specific rate
|
||||
* Set the component to 0 to make sure it stays at 100%.
|
||||
* For example you want a left to right bar but not have the height stay 100%
|
||||
* Set the rate to be ccp(0,1); and set the midpoint to = ccp(0,.5f);
|
||||
* Set the rate to be Point(0,1); and set the midpoint to = Point(0,.5f);
|
||||
*/
|
||||
CC_SYNTHESIZE(Point, _barChangeRate, BarChangeRate);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -284,7 +284,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF
|
|||
_texture = new Texture2D();
|
||||
if (_texture)
|
||||
{
|
||||
_texture->initWithData(data, (Texture2DPixelFormat)_pixelFormat, powW, powH, CCSizeMake((float)w, (float)h));
|
||||
_texture->initWithData(data, (Texture2DPixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -293,12 +293,12 @@ 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)
|
||||
{
|
||||
_textureCopy->initWithData(data, (Texture2DPixelFormat)_pixelFormat, powW, powH, CCSizeMake((float)w, (float)h));
|
||||
_textureCopy->initWithData(data, (Texture2DPixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -98,7 +98,7 @@ bool ParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
this->_emitterMode = kParticleModeGravity;
|
||||
|
||||
// Gravity Mode: gravity
|
||||
this->modeA.gravity = ccp(0,0);
|
||||
this->modeA.gravity = Point(0,0);
|
||||
|
||||
// Gravity Mode: radial acceleration
|
||||
this->modeA.radialAccel = 0;
|
||||
|
@ -113,9 +113,9 @@ bool ParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
_angleVar = 10;
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
this->setPosition(ccp(winSize.width/2, 60));
|
||||
this->_posVar = ccp(40, 20);
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Point(winSize.width/2, 60));
|
||||
this->_posVar = Point(40, 20);
|
||||
|
||||
// life of particles
|
||||
_life = 3;
|
||||
|
@ -203,7 +203,7 @@ bool ParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
this->_emitterMode = kParticleModeGravity;
|
||||
|
||||
// Gravity Mode: gravity
|
||||
this->modeA.gravity = ccp(0,-90);
|
||||
this->modeA.gravity = Point(0,-90);
|
||||
|
||||
// Gravity Mode: radial
|
||||
this->modeA.radialAccel = 0;
|
||||
|
@ -214,8 +214,8 @@ bool ParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
this->modeA.speedVar = 50;
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Point(winSize.width/2, winSize.height/2));
|
||||
|
||||
// angle
|
||||
this->_angle= 90;
|
||||
|
@ -307,7 +307,7 @@ bool ParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setEmitterMode(kParticleModeGravity);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(ccp(0,0));
|
||||
setGravity(Point(0,0));
|
||||
|
||||
// Gravity mode: radial acceleration
|
||||
setRadialAccel(0);
|
||||
|
@ -323,9 +323,9 @@ bool ParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
_angleVar = 360;
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
||||
setPosVar(PointZero);
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 1;
|
||||
|
@ -411,7 +411,7 @@ bool ParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setEmitterMode(kParticleModeGravity);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(ccp(0,0));
|
||||
setGravity(Point(0,0));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(60);
|
||||
|
@ -430,9 +430,9 @@ bool ParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
_angleVar = 360;
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
||||
setPosVar(PointZero);
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 4;
|
||||
|
@ -520,7 +520,7 @@ bool ParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setEmitterMode(kParticleModeGravity);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(ccp(0,0));
|
||||
setGravity(Point(0,0));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(80);
|
||||
|
@ -539,9 +539,9 @@ bool ParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
_angleVar = 360;
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
||||
setPosVar(PointZero);
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 4;
|
||||
|
@ -628,7 +628,7 @@ bool ParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setEmitterMode(kParticleModeGravity);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(ccp(-200,200));
|
||||
setGravity(Point(-200,200));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(15);
|
||||
|
@ -647,9 +647,9 @@ bool ParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
_angleVar = 360;
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
||||
setPosVar(PointZero);
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 2;
|
||||
|
@ -737,7 +737,7 @@ bool ParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setEmitterMode(kParticleModeGravity);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(ccp(0,0));
|
||||
setGravity(Point(0,0));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(150);
|
||||
|
@ -756,9 +756,9 @@ bool ParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
_angleVar = 0;
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
||||
setPosVar(PointZero);
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 12;
|
||||
|
@ -845,7 +845,7 @@ bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setEmitterMode(kParticleModeGravity);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(ccp(0,0));
|
||||
setGravity(Point(0,0));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(70);
|
||||
|
@ -864,9 +864,9 @@ bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
_angleVar = 360;
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
||||
setPosVar(PointZero);
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Point(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Point::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 5.0f;
|
||||
|
@ -954,7 +954,7 @@ bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setEmitterMode(kParticleModeGravity);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(ccp(0,0));
|
||||
setGravity(Point(0,0));
|
||||
|
||||
// Gravity Mode: radial acceleration
|
||||
setRadialAccel(0);
|
||||
|
@ -969,9 +969,9 @@ bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
_angleVar = 5;
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
this->setPosition(ccp(winSize.width/2, 0));
|
||||
setPosVar(ccp(20, 0));
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Point(winSize.width/2, 0));
|
||||
setPosVar(Point(20, 0));
|
||||
|
||||
// life of particles
|
||||
_life = 4;
|
||||
|
@ -1059,7 +1059,7 @@ bool ParticleSnow::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setEmitterMode(kParticleModeGravity);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(ccp(0,-1));
|
||||
setGravity(Point(0,-1));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(5);
|
||||
|
@ -1074,9 +1074,9 @@ bool ParticleSnow::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setTangentialAccelVar(1);
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
this->setPosition(ccp(winSize.width/2, winSize.height + 10));
|
||||
setPosVar(ccp(winSize.width/2, 0));
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Point(winSize.width/2, winSize.height + 10));
|
||||
setPosVar(Point(winSize.width/2, 0));
|
||||
|
||||
// angle
|
||||
_angle = -90;
|
||||
|
@ -1166,7 +1166,7 @@ bool ParticleRain::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setEmitterMode(kParticleModeGravity);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(ccp(10,-10));
|
||||
setGravity(Point(10,-10));
|
||||
|
||||
// Gravity Mode: radial
|
||||
setRadialAccel(0);
|
||||
|
@ -1186,9 +1186,9 @@ bool ParticleRain::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::sharedDirector()->getWinSize();
|
||||
this->setPosition(ccp(winSize.width/2, winSize.height));
|
||||
setPosVar(ccp(winSize.width/2, 0));
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Point(winSize.width/2, winSize.height));
|
||||
setPosVar(Point(winSize.width/2, 0));
|
||||
|
||||
// life of particles
|
||||
_life = 4.5f;
|
||||
|
|
|
@ -94,8 +94,8 @@ ParticleSystem::ParticleSystem()
|
|||
, _isActive(true)
|
||||
, _particleCount(0)
|
||||
, _duration(0)
|
||||
, _sourcePosition(PointZero)
|
||||
, _posVar(PointZero)
|
||||
, _sourcePosition(Point::ZERO)
|
||||
, _posVar(Point::ZERO)
|
||||
, _life(0)
|
||||
, _lifeVar(0)
|
||||
, _angle(0)
|
||||
|
@ -117,7 +117,7 @@ ParticleSystem::ParticleSystem()
|
|||
, _isAutoRemoveOnFinish(false)
|
||||
, _emitterMode(kParticleModeGravity)
|
||||
{
|
||||
modeA.gravity = PointZero;
|
||||
modeA.gravity = Point::ZERO;
|
||||
modeA.speed = 0;
|
||||
modeA.speedVar = 0;
|
||||
modeA.tangentialAccel = 0;
|
||||
|
@ -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");
|
||||
|
@ -248,7 +248,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
|
|||
// position
|
||||
float x = dictionary->valueForKey("sourcePositionx")->floatValue();
|
||||
float y = dictionary->valueForKey("sourcePositiony")->floatValue();
|
||||
this->setPosition( ccp(x,y) );
|
||||
this->setPosition( Point(x,y) );
|
||||
_posVar.x = dictionary->valueForKey("sourcePositionVariancex")->floatValue();
|
||||
_posVar.y = dictionary->valueForKey("sourcePositionVariancey")->floatValue();
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -523,7 +523,7 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
// position
|
||||
if( _positionType == kPositionTypeFree )
|
||||
{
|
||||
particle->startPos = this->convertToWorldSpace(PointZero);
|
||||
particle->startPos = this->convertToWorldSpace(Point::ZERO);
|
||||
}
|
||||
else if ( _positionType == kPositionTypeRelative )
|
||||
{
|
||||
|
@ -540,7 +540,7 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
float s = modeA.speed + modeA.speedVar * CCRANDOM_MINUS1_1();
|
||||
|
||||
// direction
|
||||
particle->modeA.dir = ccpMult( v, s );
|
||||
particle->modeA.dir = v * s ;
|
||||
|
||||
// radial accel
|
||||
particle->modeA.radialAccel = modeA.radialAccel + modeA.radialAccelVar * CCRANDOM_MINUS1_1();
|
||||
|
@ -551,7 +551,7 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
|
||||
// rotation is dir
|
||||
if(modeA.rotationIsDir)
|
||||
particle->rotation = -CC_RADIANS_TO_DEGREES(ccpToAngle(particle->modeA.dir));
|
||||
particle->rotation = -CC_RADIANS_TO_DEGREES(particle->modeA.dir.getAngle());
|
||||
}
|
||||
|
||||
// Mode Radius: B
|
||||
|
@ -628,10 +628,10 @@ void ParticleSystem::update(float dt)
|
|||
|
||||
_particleIdx = 0;
|
||||
|
||||
Point currentPosition = PointZero;
|
||||
Point currentPosition = Point::ZERO;
|
||||
if (_positionType == kPositionTypeFree)
|
||||
{
|
||||
currentPosition = this->convertToWorldSpace(PointZero);
|
||||
currentPosition = this->convertToWorldSpace(Point::ZERO);
|
||||
}
|
||||
else if (_positionType == kPositionTypeRelative)
|
||||
{
|
||||
|
@ -654,27 +654,27 @@ void ParticleSystem::update(float dt)
|
|||
{
|
||||
Point tmp, radial, tangential;
|
||||
|
||||
radial = PointZero;
|
||||
radial = Point::ZERO;
|
||||
// radial acceleration
|
||||
if (p->pos.x || p->pos.y)
|
||||
{
|
||||
radial = ccpNormalize(p->pos);
|
||||
radial = p->pos.normalize();
|
||||
}
|
||||
tangential = radial;
|
||||
radial = ccpMult(radial, p->modeA.radialAccel);
|
||||
radial = radial * p->modeA.radialAccel;
|
||||
|
||||
// tangential acceleration
|
||||
float newy = tangential.x;
|
||||
tangential.x = -tangential.y;
|
||||
tangential.y = newy;
|
||||
tangential = ccpMult(tangential, p->modeA.tangentialAccel);
|
||||
tangential = tangential * p->modeA.tangentialAccel;
|
||||
|
||||
// (gravity + radial + tangential) * dt
|
||||
tmp = ccpAdd( ccpAdd( radial, tangential), modeA.gravity);
|
||||
tmp = ccpMult( tmp, dt);
|
||||
p->modeA.dir = ccpAdd( p->modeA.dir, tmp);
|
||||
tmp = ccpMult(p->modeA.dir, dt);
|
||||
p->pos = ccpAdd( p->pos, tmp );
|
||||
tmp = radial + tangential + modeA.gravity;
|
||||
tmp = tmp * dt;
|
||||
p->modeA.dir = p->modeA.dir + tmp;
|
||||
tmp = p->modeA.dir * dt;
|
||||
p->pos = p->pos + tmp;
|
||||
}
|
||||
|
||||
// Mode B: radius movement
|
||||
|
@ -709,8 +709,8 @@ void ParticleSystem::update(float dt)
|
|||
|
||||
if (_positionType == kPositionTypeFree || _positionType == kPositionTypeRelative)
|
||||
{
|
||||
Point diff = ccpSub( currentPosition, p->startPos );
|
||||
newPos = ccpSub(p->pos, diff);
|
||||
Point diff = currentPosition - p->startPos;
|
||||
newPos = p->pos - diff;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
@ -133,7 +133,7 @@ void ParticleSystemQuad::initTexCoordsWithRect(const Rect& pointRect)
|
|||
{
|
||||
// convert to Tex coords
|
||||
|
||||
Rect rect = CCRectMake(
|
||||
Rect rect = Rect(
|
||||
pointRect.origin.x * CC_CONTENT_SCALE_FACTOR(),
|
||||
pointRect.origin.y * CC_CONTENT_SCALE_FACTOR(),
|
||||
pointRect.size.width * CC_CONTENT_SCALE_FACTOR(),
|
||||
|
@ -207,11 +207,11 @@ void ParticleSystemQuad::setTextureWithRect(Texture2D *texture, const Rect& rect
|
|||
void ParticleSystemQuad::setTexture(Texture2D* texture)
|
||||
{
|
||||
const Size& s = texture->getContentSize();
|
||||
this->setTextureWithRect(texture, CCRectMake(0, 0, s.width, s.height));
|
||||
this->setTextureWithRect(texture, Rect(0, 0, s.width, s.height));
|
||||
}
|
||||
void ParticleSystemQuad::setDisplayFrame(SpriteFrame *spriteFrame)
|
||||
{
|
||||
CCAssert(spriteFrame->getOffsetInPixels().equals(PointZero),
|
||||
CCAssert(spriteFrame->getOffsetInPixels().equals(Point::ZERO),
|
||||
"QuadParticle only supports SpriteFrames with no offsets");
|
||||
|
||||
// update texture before updating texture rect
|
||||
|
|
|
@ -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
|
||||
|
@ -115,14 +115,14 @@ const Size& EGLViewProtocol::getFrameSize() const
|
|||
|
||||
void EGLViewProtocol::setFrameSize(float width, float height)
|
||||
{
|
||||
_designResolutionSize = _screenSize = CCSizeMake(width, height);
|
||||
_designResolutionSize = _screenSize = Size(width, height);
|
||||
}
|
||||
|
||||
Size EGLViewProtocol::getVisibleSize() const
|
||||
{
|
||||
if (_resolutionPolicy == kResolutionNoBorder)
|
||||
{
|
||||
return CCSizeMake(_screenSize.width/_scaleX, _screenSize.height/_scaleY);
|
||||
return Size(_screenSize.width/_scaleX, _screenSize.height/_scaleY);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -134,12 +134,12 @@ Point EGLViewProtocol::getVisibleOrigin() const
|
|||
{
|
||||
if (_resolutionPolicy == kResolutionNoBorder)
|
||||
{
|
||||
return CCPointMake((_designResolutionSize.width - _screenSize.width/_scaleX)/2,
|
||||
return Point((_designResolutionSize.width - _screenSize.width/_scaleX)/2,
|
||||
(_designResolutionSize.height - _screenSize.height/_scaleY)/2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PointZero;
|
||||
return Point::ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ Rect EGLViewProtocol::getScissorRect()
|
|||
float y = (params[1] - _viewPortRect.origin.y) / _scaleY;
|
||||
float w = params[2] / _scaleX;
|
||||
float h = params[3] / _scaleY;
|
||||
return CCRectMake(x, y, w, h);
|
||||
return Rect(x, y, w, h);
|
||||
}
|
||||
|
||||
void EGLViewProtocol::setViewName(const char* pszViewName)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -54,7 +54,7 @@ extern "C" {
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -9,7 +9,7 @@ using namespace std;
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -9,7 +9,7 @@ using namespace std;
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -91,7 +91,7 @@ static id s_sharedDirectorCaller;
|
|||
|
||||
-(void) doCaller: (id) sender
|
||||
{
|
||||
cocos2d::Director::sharedDirector()->mainLoop();
|
||||
cocos2d::Director::getInstance()->mainLoop();
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -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();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -18,7 +18,7 @@ using namespace std;
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue