Merge branch 'master' of https://github.com/cocos2d/cocos2d-x into LinuxPort

Conflicts:
	cocos2dx/actions/CCActionInstant.cpp
	cocos2dx/include/CCActionInstant.h
This commit is contained in:
laschweinski 2011-09-04 14:38:53 +08:00
commit 1fc09448a4
37 changed files with 423 additions and 452 deletions

View File

@ -178,7 +178,7 @@ namespace CocosDenshion
if (s3eSoundGetError()!= S3E_SOUND_ERR_NONE)
{
IwAssertMsg(GAME, this, ("Play sound %s Failed. Error Code : %s", pszFilePath, s3eSoundGetErrorString()));
IwAssertMsg(GAME, false, ("Play sound %s Failed. Error Code : %s", pszFilePath, s3eSoundGetErrorString()));
}
return channel;

View File

@ -61,7 +61,7 @@ namespace CocosDenshion
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
{
preloadBackgroundMusicJNI(pszFilePath);
}
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)

View File

@ -55,6 +55,18 @@ extern "C"
return ret;
}
void preloadBackgroundMusicJNI(const char *path)
{
// void playBackgroundMusic(String,boolean)
jmethodID preloadBackgroundMusicMethodID = getMethodID("preloadBackgroundMusic", "(Ljava/lang/String;)V");
if (preloadBackgroundMusicMethodID)
{
jstring StringArg = env->NewStringUTF(path);
env->CallStaticVoidMethod(classOfCocos2dxActivity, preloadBackgroundMusicMethodID, StringArg);
}
}
void playBackgroundMusicJNI(const char *path, bool isLoop)
{
// void playBackgroundMusic(String,boolean)

View File

@ -5,6 +5,7 @@
extern "C"
{
extern void preloadBackgroundMusicJNI(const char *path);
extern void playBackgroundMusicJNI(const char *path, bool isLoop);
extern void stopBackgroundMusicJNI();
extern void pauseBackgroundMusicJNI();

View File

@ -120,6 +120,10 @@ public class Cocos2dxActivity extends Activity{
accelerometer.disable();
}
public static void preloadBackgroundMusic(String path){
backgroundMusicPlayer.preloadBackgroundMusic(path);
}
public static void playBackgroundMusic(String path, boolean isLoop){
backgroundMusicPlayer.playBackgroundMusic(path, isLoop);
}

View File

@ -25,6 +25,22 @@ public class Cocos2dxMusic {
initData();
}
public void preloadBackgroundMusic(String path){
if ((mCurrentPath == null) || (! mCurrentPath.equals(path))){
// preload new background music
// release old resource and create a new one
if (mBackgroundMediaPlayer != null){
mBackgroundMediaPlayer.release();
}
mBackgroundMediaPlayer = createMediaplayerFromAssets(path);
// record the path
mCurrentPath = path;
}
}
public void playBackgroundMusic(String path, boolean isLoop){
if (mCurrentPath == null){
// it is the first time to play background music

View File

@ -40,6 +40,7 @@ namespace cocos2d {
{
CCZone *pNewZone = NULL;
CCActionInstant *pRet = NULL;
if (pZone && pZone->m_pCopyObject)
{
pRet = (CCActionInstant*)(pZone->m_pCopyObject);
@ -49,24 +50,29 @@ namespace cocos2d {
pRet = new CCActionInstant();
pZone = pNewZone = new CCZone(pRet);
}
CCFiniteTimeAction::copyWithZone(pZone);
CC_SAFE_DELETE(pNewZone);
return pRet;
}
bool CCActionInstant::isDone()
{
return true;
}
void CCActionInstant::step(ccTime dt)
{
CC_UNUSED_PARAM(dt);
update(1);
}
void CCActionInstant::update(ccTime time)
{
CC_UNUSED_PARAM(time);
// ignore
}
CCFiniteTimeAction * CCActionInstant::reverse()
{
return (CCFiniteTimeAction*)(copy()->autorelease());
@ -78,22 +84,29 @@ namespace cocos2d {
CCShow* CCShow::action()
{
CCShow* pRet = new CCShow();
pRet->autorelease();
if (pRet)
{
pRet->autorelease();
}
return pRet;
}
void CCShow::startWithTarget(CCNode *pTarget)
{
CCActionInstant::startWithTarget(pTarget);
pTarget->setIsVisible(true);
}
CCFiniteTimeAction *CCShow::reverse()
CCFiniteTimeAction* CCShow::reverse()
{
return (CCFiniteTimeAction*)(CCHide::action());
}
CCObject* CCShow::copyWithZone(CCZone *pZone){
CCZone *pNewZone = NULL;
CCActionInstant *pRet = NULL;
CCObject* CCShow::copyWithZone(CCZone *pZone)
{
if (pZone && pZone->m_pCopyObject)
{
pRet = (CCShow*)(pZone->m_pCopyObject);
@ -103,19 +116,27 @@ namespace cocos2d {
pRet = new CCShow();
pZone = pNewZone = new CCZone(pRet);
}
CCActionInstant::copyWithZone(pZone);
CCFiniteTimeAction::copyWithZone(pZone);
CC_SAFE_DELETE(pNewZone);
return pRet;
}
//
// Hide
//
CCHide * CCHide::action()
{
CCHide *pRet = new CCHide();
pRet->autorelease();
if (pRet)
{
pRet->autorelease();
}
return pRet;
}
void CCHide::startWithTarget(CCNode *pTarget)
{
CCActionInstant::startWithTarget(pTarget);
@ -127,9 +148,11 @@ namespace cocos2d {
return (CCFiniteTimeAction*)(CCShow::action());
}
CCObject* CCHide::copyWithZone(CCZone *pZone){
CCObject* CCHide::copyWithZone(CCZone *pZone)
{
CCZone *pNewZone = NULL;
CCActionInstant *pRet = NULL;
CCHide *pRet = NULL;
if (pZone && pZone->m_pCopyObject)
{
pRet = (CCHide*)(pZone->m_pCopyObject);
@ -139,7 +162,8 @@ namespace cocos2d {
pRet = new CCHide();
pZone = pNewZone = new CCZone(pRet);
}
CCActionInstant::copyWithZone(pZone);
CCFiniteTimeAction::copyWithZone(pZone);
CC_SAFE_DELETE(pNewZone);
return pRet;
}
@ -150,29 +174,44 @@ namespace cocos2d {
CCToggleVisibility * CCToggleVisibility::action()
{
CCToggleVisibility *pRet = new CCToggleVisibility();
pRet->autorelease();
if (pRet)
{
pRet->autorelease();
}
return pRet;
}
void CCToggleVisibility::startWithTarget(CCNode *pTarget)
{
CCActionInstant::startWithTarget(pTarget);
pTarget->setIsVisible(! pTarget->getIsVisible());
}
//
// FlipX
//
CCFlipX *CCFlipX::actionWithFlipX(bool x)
{
CCFlipX *pRet = new CCFlipX();
pRet->initWithFlipX(x);
pRet->autorelease();
return pRet;
if (pRet && pRet->initWithFlipX(x))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet)
return NULL;
}
bool CCFlipX::initWithFlipX(bool x)
{
m_bFlipX = x;
return true;
}
void CCFlipX::startWithTarget(CCNode *pTarget)
{
CCActionInstant::startWithTarget(pTarget);
@ -188,6 +227,7 @@ namespace cocos2d {
{
CCZone *pNewZone = NULL;
CCFlipX *pRet = NULL;
if (pZone && pZone->m_pCopyObject)
{
pRet = (CCFlipX*)(pZone->m_pCopyObject);
@ -197,6 +237,7 @@ namespace cocos2d {
pRet = new CCFlipX();
pZone = pNewZone = new CCZone(pRet);
}
CCActionInstant::copyWithZone(pZone);
pRet->initWithFlipX(m_bFlipX);
CC_SAFE_DELETE(pNewZone);
@ -209,10 +250,17 @@ namespace cocos2d {
CCFlipY * CCFlipY::actionWithFlipY(bool y)
{
CCFlipY *pRet = new CCFlipY();
pRet->initWithFlipY(y);
pRet->autorelease();
return pRet;
if (pRet &&pRet->initWithFlipY(y))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
bool CCFlipY::initWithFlipY(bool y)
{
m_bFlipY = y;
@ -230,10 +278,11 @@ namespace cocos2d {
return CCFlipY::actionWithFlipY(!m_bFlipY);
}
CCObject * CCFlipY::copyWithZone(CCZone *pZone)
CCObject* CCFlipY::copyWithZone(CCZone *pZone)
{
CCZone *pNewZone = NULL;
CCFlipY *pRet = NULL;
if (pZone && pZone->m_pCopyObject)
{
pRet = (CCFlipY*)(pZone->m_pCopyObject);
@ -243,6 +292,7 @@ namespace cocos2d {
pRet = new CCFlipY();
pZone = pNewZone = new CCZone(pRet);
}
CCActionInstant::copyWithZone(pZone);
pRet->initWithFlipY(m_bFlipY);
CC_SAFE_DELETE(pNewZone);
@ -252,13 +302,20 @@ namespace cocos2d {
//
// Place
//
CCPlace * CCPlace::actionWithPosition(const CCPoint& pos)
CCPlace* CCPlace::actionWithPosition(const CCPoint& pos)
{
CCPlace *pRet = new CCPlace();
pRet->initWithPosition(pos);
pRet->autorelease();
return pRet;
if (pRet && pRet->initWithPosition(pos))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
bool CCPlace::initWithPosition(const CCPoint& pos)
{
m_tPosition = pos;
@ -269,6 +326,7 @@ namespace cocos2d {
{
CCZone *pNewZone = NULL;
CCPlace *pRet = NULL;
if (pZone && pZone->m_pCopyObject)
{
pRet = (CCPlace*)(pZone->m_pCopyObject);
@ -278,6 +336,7 @@ namespace cocos2d {
pRet = new CCPlace();
pZone = pNewZone = new CCZone(pRet);
}
CCActionInstant::copyWithZone(pZone);
pRet->initWithPosition(m_tPosition);
CC_SAFE_DELETE(pNewZone);
@ -297,12 +356,14 @@ namespace cocos2d {
CCCallFunc * CCCallFunc::actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFunc selector)
{
CCCallFunc *pRet = new CCCallFunc();
if(pRet->initWithTarget(pSelectorTarget))
if(pRet && pRet->initWithTarget(pSelectorTarget))
{
pRet->m_pCallFunc = selector;
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
@ -310,11 +371,13 @@ namespace cocos2d {
CCCallFunc* CCCallFunc::actionWithScriptFuncName(const char* pszFuncName)
{
CCCallFunc *pRet = new CCCallFunc();
if(pRet->initWithScriptFuncName(pszFuncName))
if(pRet && pRet->initWithScriptFuncName(pszFuncName))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
@ -331,10 +394,12 @@ namespace cocos2d {
{
pSelectorTarget->selectorProtocolRetain();
}
if (m_pSelectorTarget)
{
m_pSelectorTarget->selectorProtocolRelease();
}
m_pSelectorTarget = pSelectorTarget;
return true;
}
@ -343,13 +408,18 @@ namespace cocos2d {
{
CCZone* pNewZone = NULL;
CCCallFunc* pRet = NULL;
if(pZone && pZone->m_pCopyObject) //in case of being called at sub class
if(pZone && pZone->m_pCopyObject)
{
//in case of being called at sub class
pRet = (CCCallFunc*)(pZone->m_pCopyObject);
}
else
{
pRet = new CCCallFunc();
pZone = pNewZone = new CCZone(pRet);
}
CCActionInstant::copyWithZone(pZone);
pRet->initWithTarget(m_pSelectorTarget);
pRet->m_pCallFunc = m_pCallFunc;
@ -357,11 +427,13 @@ namespace cocos2d {
CC_SAFE_DELETE(pNewZone);
return pRet;
}
void CCCallFunc::startWithTarget(CCNode *pTarget)
{
CCActionInstant::startWithTarget(pTarget);
this->execute();
}
void CCCallFunc::execute()
{
if(m_pCallFunc)
@ -374,6 +446,7 @@ namespace cocos2d {
CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeCallFunc(m_scriptFuncName.c_str());
}
}
//
// CallFuncN
//
@ -390,14 +463,17 @@ namespace cocos2d {
m_pTarget);
}
}
CCCallFuncN * CCCallFuncN::actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncN selector)
{
CCCallFuncN *pRet = new CCCallFuncN();
if(pRet->initWithTarget(pSelectorTarget, selector))
if(pRet && pRet->initWithTarget(pSelectorTarget, selector))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
@ -405,22 +481,25 @@ namespace cocos2d {
CCCallFuncN* CCCallFuncN::actionWithScriptFuncName(const char *pszFuncName)
{
CCCallFuncN *pRet = new CCCallFuncN();
if(pRet->initWithScriptFuncName(pszFuncName))
if(pRet && pRet->initWithScriptFuncName(pszFuncName))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
bool CCCallFuncN::initWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncN selector)
{
if( CCCallFunc::initWithTarget(pSelectorTarget) )
if(CCCallFunc::initWithTarget(pSelectorTarget))
{
m_pCallFuncN = selector;
return true;
}
return false;
}
@ -428,29 +507,37 @@ namespace cocos2d {
{
CCZone* pNewZone = NULL;
CCCallFuncN* pRet = NULL;
if(zone && zone->m_pCopyObject) //in case of being called at sub class
if(zone && zone->m_pCopyObject)
{
//in case of being called at sub class
pRet = (CCCallFuncN*)(zone->m_pCopyObject);
}
else
{
pRet = new CCCallFuncN();
zone = pNewZone = new CCZone(pRet);
}
CCCallFunc::copyWithZone(zone);
pRet->initWithTarget(m_pSelectorTarget, m_pCallFuncN);
CC_SAFE_DELETE(pNewZone);
return pRet;
}
//
// CallFuncND
//
CCCallFuncND * CCCallFuncND::actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncND selector, void* d)
{
CCCallFuncND* pRet = new CCCallFuncND();
if (pRet->initWithTarget(pSelectorTarget, selector, d))
if (pRet && pRet->initWithTarget(pSelectorTarget, selector, d))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
@ -458,12 +545,14 @@ namespace cocos2d {
CCCallFuncND* CCCallFuncND::actionWithScriptFuncName(const char* pszFuncName, void *d)
{
CCCallFuncND* pRet = new CCCallFuncND();
if (pRet->initWithScriptFuncName(pszFuncName))
if (pRet && pRet->initWithScriptFuncName(pszFuncName))
{
pRet->autorelease();
pRet->m_pData = d;
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
@ -476,6 +565,7 @@ namespace cocos2d {
m_pCallFuncND = selector;
return true;
}
return false;
}
@ -483,13 +573,18 @@ namespace cocos2d {
{
CCZone* pNewZone = NULL;
CCCallFuncND* pRet = NULL;
if(zone && zone->m_pCopyObject) //in case of being called at sub class
if(zone && zone->m_pCopyObject)
{
//in case of being called at sub class
pRet = (CCCallFuncND*)(zone->m_pCopyObject);
}
else
{
pRet = new CCCallFuncND();
zone = pNewZone = new CCZone(pRet);
}
CCCallFunc::copyWithZone(zone);
pRet->initWithTarget(m_pSelectorTarget, m_pCallFuncND, m_pData);
CC_SAFE_DELETE(pNewZone);
@ -508,8 +603,7 @@ namespace cocos2d {
CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeCallFuncND(m_scriptFuncName.c_str(),
m_pTarget,
m_pData);
}
}
}
//
@ -538,14 +632,17 @@ namespace cocos2d {
m_pObject);
}
}
CCCallFuncO * CCCallFuncO::actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject)
{
CCCallFuncO *pRet = new CCCallFuncO();
if(pRet->initWithTarget(pSelectorTarget, selector, pObject))
if(pRet && pRet->initWithTarget(pSelectorTarget, selector, pObject))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
@ -553,11 +650,13 @@ namespace cocos2d {
CCCallFuncO* CCCallFuncO::actionWithScriptFuncName(const char *pszFuncName)
{
CCCallFuncO *pRet = new CCCallFuncO();
if(pRet->initWithScriptFuncName(pszFuncName))
if(pRet && pRet->initWithScriptFuncName(pszFuncName))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
@ -572,23 +671,29 @@ namespace cocos2d {
m_pCallFuncO = selector;
return true;
}
return false;
}
CCObject * CCCallFuncO::copyWithZone(CCZone* zone)
{
CCZone* pNewZone = NULL;
CCCallFuncO* pRet = NULL;
if(zone && zone->m_pCopyObject) //in case of being called at sub class
if(zone && zone->m_pCopyObject)
{
//in case of being called at sub class
pRet = (CCCallFuncO*)(zone->m_pCopyObject);
}
else
{
pRet = new CCCallFuncO();
zone = pNewZone = new CCZone(pRet);
}
CCCallFunc::copyWithZone(zone);
pRet->initWithTarget(m_pSelectorTarget, m_pCallFuncO, m_pObject);
CC_SAFE_DELETE(pNewZone);
return pRet;
}
}

View File

@ -1010,7 +1010,7 @@ void CCSkewTo::startWithTarget(CCNode *pTarget)
m_fDeltaX += 360;
}
m_fSkewY = pTarget->getSkewY();
m_fStartSkewY = pTarget->getSkewY();
if (m_fStartSkewY > 0)
{

View File

@ -49,11 +49,6 @@ class CC_DLL CCAccelerometerDelegate
{
public:
virtual void didAccelerate(CCAcceleration* pAccelerationValue) {CC_UNUSED_PARAM(pAccelerationValue);}
//! call the release() in child layer
virtual void AccelerometerDestroy(void) {}
//! call the retain() in child layer
virtual void AccelerometerKeep(void) {}
};
} //namespace cocos2d

View File

@ -61,7 +61,6 @@ namespace cocos2d {
//super methods
virtual void startWithTarget(CCNode *pTarget);
virtual CCFiniteTimeAction * reverse(void);
//add
virtual CCObject* copyWithZone(CCZone *pZone);
public:
//override static method
@ -82,7 +81,6 @@ namespace cocos2d {
//super methods
virtual void startWithTarget(CCNode *pTarget);
virtual CCFiniteTimeAction * reverse(void);
//add
virtual CCObject* copyWithZone(CCZone *pZone);
public:
//override static method

View File

@ -67,8 +67,6 @@ public:
virtual void keep(void);
virtual void didAccelerate(CCAcceleration* pAccelerationValue) {CC_UNUSED_PARAM(pAccelerationValue);}
virtual void AccelerometerDestroy(void);
virtual void AccelerometerKeep(void);
virtual void KeypadDestroy();
virtual void KeypadKeep();

View File

@ -198,7 +198,7 @@ public:
static CCSprite* spriteWithBatchNode(CCSpriteBatchNode *batchNode, const CCRect& rect);
public:
bool init(void);
virtual bool init(void);
virtual ~CCSprite(void);
CCSprite();

View File

@ -174,7 +174,7 @@ It should work same as apples CFSwapInt32LittleToHost(..)
/// when define returns true it means that our architecture uses big endian
#define CC_HOST_IS_BIG_ENDIAN (bool)(*(unsigned short *)"\0\xff" < 0x100)
#define CC_SWAP32(i) ((i & 0x000000ff) << 24 | (i & 0x0000ff00 << 8) | (i & 0x00ff0000) >> 8 | (i & 0xff000000) >> 24)
#define CC_SWAP32(i) ((i & 0x000000ff) << 24 | (i & 0x0000ff00) << 8 | (i & 0x00ff0000) >> 8 | (i & 0xff000000) >> 24)
#define CC_SWAP16(i) ((i & 0x00ff) << 8 | (i &0xff00) >> 8)
#define CC_SWAP_INT32_LITTLE_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP32(i) : (i) )
#define CC_SWAP_INT16_LITTLE_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP16(i) : (i) )

View File

@ -96,16 +96,6 @@ void CCLayer::keep(void)
this->retain();
}
void CCLayer::AccelerometerDestroy(void)
{
this->release();
}
void CCLayer::AccelerometerKeep(void)
{
this->retain();
}
void CCLayer::KeypadDestroy()
{
this->release();
@ -158,11 +148,11 @@ void CCLayer::setIsAccelerometerEnabled(bool enabled)
{
if (enabled)
{
CCAccelerometer::sharedAccelerometer()->addDelegate(this);
CCAccelerometer::sharedAccelerometer()->setDelegate(this);
}
else
{
CCAccelerometer::sharedAccelerometer()->removeDelegate(this);
CCAccelerometer::sharedAccelerometer()->setDelegate(NULL);
}
}
}
@ -210,7 +200,7 @@ void CCLayer::onEnter()
// add this layer to concern the Accelerometer Sensor
if (m_bIsAccelerometerEnabled)
{
CCAccelerometer::sharedAccelerometer()->addDelegate(this);
CCAccelerometer::sharedAccelerometer()->setDelegate(this);
}
// add this layer to concern the kaypad msg
@ -230,7 +220,7 @@ void CCLayer::onExit()
// remove this layer from the delegates who concern Accelerometer Sensor
if (m_bIsAccelerometerEnabled)
{
CCAccelerometer::sharedAccelerometer()->removeDelegate(this);
CCAccelerometer::sharedAccelerometer()->setDelegate(NULL);
}
// remove this layer from the delegates who concern the kaypad msg
@ -246,7 +236,7 @@ void CCLayer::onEnterTransitionDidFinish()
{
if (m_bIsAccelerometerEnabled)
{
CCAccelerometer::sharedAccelerometer()->addDelegate(this);
CCAccelerometer::sharedAccelerometer()->setDelegate(this);
}
CCNode::onEnterTransitionDidFinish();

View File

@ -58,6 +58,10 @@ typedef enum LanguageType
{
kLanguageEnglish = 0,
kLanguageChinese,
kLanguageFrench,
kLanguageItalian,
kLanguageGerman,
kLanguageSpanish,
} ccLanguageType;
NS_CC_END;

View File

@ -76,6 +76,9 @@ public:
/**
@brief Set the ResourcePath,we will find resource in this path
@param pszResourcePath The absolute resource path
@warning Don't call this function in android and iOS, it has not effect.
In android, if you want to read file other than apk, you shoud use invoke getFileData(), and pass the
absolute path.
*/
static void setResourcePath(const char *pszResourcePath);

View File

@ -34,18 +34,17 @@ namespace cocos2d
{
CCAccelerometer* CCAccelerometer::m_spCCAccelerometer = NULL;
CCAccelerometer::CCAccelerometer() {
m_pAccelDelegates = new std::list<CCAccelerometerDelegate*>();
CCAccelerometer::CCAccelerometer() : m_pAccelDelegate(NULL)
{
}
CCAccelerometer::~CCAccelerometer() {
if ( m_pAccelDelegates ) {
delete m_pAccelDelegates;
m_pAccelDelegates = NULL;
}
CCAccelerometer::~CCAccelerometer()
{
m_spCCAccelerometer = NULL;
}
CCAccelerometer* CCAccelerometer::sharedAccelerometer() {
CCAccelerometer* CCAccelerometer::sharedAccelerometer()
{
if (m_spCCAccelerometer == NULL)
{
@ -55,34 +54,31 @@ namespace cocos2d
return m_spCCAccelerometer;
}
void CCAccelerometer::removeDelegate(CCAccelerometerDelegate* pDelegate) {
m_pAccelDelegates->remove(pDelegate);
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
{
m_pAccelDelegate = pDelegate;
if ( 0 == m_pAccelDelegates->size() ) {
disableAccelerometerJNI();
}
if (pDelegate)
{
enableAccelerometerJNI();
}
else
{
disableAccelerometerJNI();
}
}
void CCAccelerometer::addDelegate(CCAccelerometerDelegate* pDelegate) {
if ( 0 == m_pAccelDelegates->size() ) {
enableAccelerometerJNI();
}
void CCAccelerometer::update(float x, float y, float z, long sensorTimeStamp)
{
if (m_pAccelDelegate)
{
m_obAccelerationValue.x = -((double)x / TG3_GRAVITY_EARTH);
m_obAccelerationValue.y = -((double)y / TG3_GRAVITY_EARTH);
m_obAccelerationValue.z = -((double)z / TG3_GRAVITY_EARTH);
m_obAccelerationValue.timestamp = (double)sensorTimeStamp;
m_pAccelDelegates->push_front(pDelegate);
}
void CCAccelerometer::update(float x, float y, float z, long sensorTimeStamp) {
if ( m_pAccelDelegates != NULL && !m_pAccelDelegates->empty() ) {
m_obAccelerationValue.x = -((double)x / TG3_GRAVITY_EARTH);
m_obAccelerationValue.y = -((double)y / TG3_GRAVITY_EARTH);
m_obAccelerationValue.z = -((double)z / TG3_GRAVITY_EARTH);
m_obAccelerationValue.timestamp = (double)sensorTimeStamp;
for(std::list<CCAccelerometerDelegate*>::const_iterator it = m_pAccelDelegates->begin(); it != m_pAccelDelegates->end(); ++it)
{
(*it)->didAccelerate(&m_obAccelerationValue);
}
}
m_pAccelDelegate->didAccelerate(&m_obAccelerationValue);
}
}
} // end of namespace cococs2d

View File

@ -27,7 +27,6 @@ THE SOFTWARE.
#include "CCCommon.h"
#include "CCAccelerometerDelegate.h"
#include <list>
namespace cocos2d {
@ -39,13 +38,12 @@ public:
static CCAccelerometer* sharedAccelerometer();
void removeDelegate(CCAccelerometerDelegate* pDelegate);
void addDelegate(CCAccelerometerDelegate* pDelegate);
void setDelegate(CCAccelerometerDelegate* pDelegate);
void update(float x, float y, float z, long sensorTimeStamp);
private:
static CCAccelerometer* m_spCCAccelerometer;
std::list<CCAccelerometerDelegate*>* m_pAccelDelegates;
CCAccelerometerDelegate* m_pAccelDelegate;
CCAcceleration m_obAccelerationValue;
};

View File

@ -89,7 +89,23 @@ ccLanguageType CCApplication::getCurrentLanguage()
{
ret = kLanguageEnglish;
}
else if (0 == strcmp("fr", pLanguageName))
{
ret = kLanguageFrench;
}
else if (0 == strcmp("it", pLanguageName))
{
ret = kLanguageItalian;
}
else if (0 == strcmp("de", pLanguageName))
{
ret = kLanguageGerman;
}
else if (0 == strcmp("es", pLanguageName))
{
ret = kLanguageSpanish;
}
return ret;
}

View File

@ -27,48 +27,32 @@ NS_CC_BEGIN;
#include "CCCommon.h"
#include "jni/SystemInfoJni.h"
#define MAX_PATH 256
// record the resource path
static string s_strResourcePath = "";
/*
* This function is implemented for jni to set apk path.
*/
void CCFileUtils::setResourcePath(const char* pszResourcePath)
{
CCAssert(pszResourcePath != NULL, "[FileUtils setRelativePath] -- wrong relative path");
if (! pszResourcePath)
string tmp(pszResourcePath);
if ((! pszResourcePath) || tmp.find(".apk") == string::npos)
{
return;
}
s_strResourcePath = pszResourcePath;
/*
* If the path is set by user, and not end with "/", append it
*/
if (s_strResourcePath.find(".apk") == string::npos
&& s_strResourcePath.find_last_of("/") != s_strResourcePath.length() - 1)
{
s_strResourcePath += "/";
}
s_strResourcePath = pszResourcePath;
}
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{
if (s_strResourcePath.find(".apk") != string::npos)
{
return pszRelativePath;
}
else
{
CCString *pRet = new CCString();
pRet->autorelease();
pRet->m_sString = s_strResourcePath + pszRelativePath;
return pRet->m_sString.c_str();
}
return pszRelativePath;
}
const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
const char* CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
{
std::string relativeFile = pszRelativeFile;
CCString *pRet = new CCString();
@ -79,11 +63,16 @@ const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const
}
unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
{
string fullPath = pszFileName;
{
unsigned char * pData = 0;
string fullPath(pszFileName);
if (s_strResourcePath.find(".apk") != string::npos)
if ((! pszFileName) || (! pszMode))
{
return 0;
}
if (pszFileName[0] != '/')
{
// read from apk
fullPath.insert(0, "assets/");
@ -97,12 +86,18 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
FILE *fp = fopen(pszFileName, pszMode);
CC_BREAK_IF(!fp);
unsigned long size;
fseek(fp,0,SEEK_END);
*pSize = ftell(fp);
size = ftell(fp);
fseek(fp,0,SEEK_SET);
pData = new unsigned char[*pSize];
*pSize = fread(pData,sizeof(unsigned char), *pSize,fp);
pData = new unsigned char[size];
size = fread(pData,sizeof(unsigned char), size,fp);
fclose(fp);
if (pSize)
{
*pSize = size;
}
} while (0);
}
@ -113,6 +108,7 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
msg.append(fullPath.c_str()).append(") failed!");
CCMessageBox(msg.c_str(), title.c_str());
}
return pData;
}

View File

@ -28,27 +28,15 @@
@interface AccelerometerDispatcher : NSObject<UIAccelerometerDelegate>
{
NSMutableArray *delegateWrappers;
cocos2d::CCAccelerometerDelegate *delegate_;
cocos2d::CCAcceleration *acceleration_;
}
@property(readwrite, retain) NSMutableArray* delegateWrappers;
@property(readwrite) cocos2d::CCAccelerometerDelegate *delegate_;
@property(readwrite) cocos2d::CCAcceleration *acceleration_;
+ (id) sharedAccelerometerDispather;
- (id) init;
- (void) addDelegate: (cocos2d::CCAccelerometerDelegate *) delegate;
- (void) removeDelegate: (cocos2d::CCAccelerometerDelegate *) delegate;
@end
@interface AccelerometerDelegateWrapper : NSObject {
cocos2d::CCAccelerometerDelegate *delegate_;
}
@property(readwrite) cocos2d::CCAccelerometerDelegate *delegate_;
+ (id) delegateWrapperWithDelegate:(cocos2d::CCAccelerometerDelegate *)delegate;
- (id) initWithDelegate: (cocos2d::CCAccelerometerDelegate *)delegate;
- (void) didAccelerate: (cocos2d::CCAcceleration *)acceleration;
@end

View File

@ -28,7 +28,8 @@
static AccelerometerDispatcher* s_pAccelerometerDispatcher;
@synthesize delegateWrappers;
@synthesize delegate_;
@synthesize acceleration_;
+ (id) sharedAccelerometerDispather
{
@ -41,107 +42,69 @@ static AccelerometerDispatcher* s_pAccelerometerDispatcher;
- (id) init
{
self.delegateWrappers = [NSMutableArray arrayWithCapacity:4];
[[UIAccelerometer sharedAccelerometer] setDelegate: self];
acceleration_ = new cocos2d::CCAcceleration();
return self;
}
- (void) dealloc
{
[[UIAccelerometer sharedAccelerometer] setDelegate: nil];
[delegateWrappers release];
s_pAccelerometerDispatcher = 0;
delegate_ = 0;
delete acceleration_;
[super dealloc];
}
- (id) findDelegateWrapperByDelegate: (cocos2d::CCAccelerometerDelegate *) delegate
{
for (AccelerometerDelegateWrapper *wrapper in delegateWrappers) {
if (wrapper.delegate_ == delegate) {
return wrapper;
}
}
return nil;
}
- (void) addDelegate: (cocos2d::CCAccelerometerDelegate *) delegate
{
[delegateWrappers addObject: [AccelerometerDelegateWrapper delegateWrapperWithDelegate:delegate]];
}
- (void) removeDelegate: (cocos2d::CCAccelerometerDelegate *) delegate
{
[delegateWrappers removeObject:[self findDelegateWrapperByDelegate:delegate]];
delegate_ = delegate;
if (delegate_)
{
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
}
else
{
[[UIAccelerometer sharedAccelerometer] setDelegate:nil];
}
}
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
cocos2d::CCAcceleration accelerationCpp;
{
if (! delegate_)
{
return;
}
accelerationCpp.x = acceleration.x;
accelerationCpp.y = acceleration.y;
accelerationCpp.z = acceleration.z;
accelerationCpp.timestamp = acceleration.timestamp;
acceleration_->x = acceleration.x;
acceleration_->y = acceleration.y;
acceleration_->z = acceleration.z;
acceleration_->timestamp = acceleration.timestamp;
double tmp = accelerationCpp.x;
double tmp = acceleration_->x;
switch ([[UIApplication sharedApplication] statusBarOrientation])
{
case UIInterfaceOrientationLandscapeRight:
accelerationCpp.x = -acceleration.y;
accelerationCpp.y = tmp;
acceleration_->x = -acceleration_->y;
acceleration_->y = tmp;
break;
case UIInterfaceOrientationLandscapeLeft:
accelerationCpp.x = acceleration.y;
accelerationCpp.y = -tmp;
acceleration_->x = acceleration_->y;
acceleration_->y = -tmp;
break;
case UIInterfaceOrientationPortraitUpsideDown:
accelerationCpp.x = -accelerationCpp.y;
accelerationCpp.y = -tmp;
acceleration_->x = -acceleration_->y;
acceleration_->y = -tmp;
break;
case UIInterfaceOrientationPortrait:
break;
}
for (AccelerometerDelegateWrapper *wrapper in delegateWrappers) {
[wrapper didAccelerate: &accelerationCpp];
}
delegate_->didAccelerate(acceleration_);
}
@end
@implementation AccelerometerDelegateWrapper
@synthesize delegate_;
+ (id)delegateWrapperWithDelegate:(cocos2d::CCAccelerometerDelegate *)delegate
{
return [[self alloc] initWithDelegate: delegate];
}
- (id) initWithDelegate: (cocos2d::CCAccelerometerDelegate *)delegate
{
delegate->AccelerometerKeep();
self.delegate_ = delegate;
return self;
}
- (void) didAccelerate: (cocos2d::CCAcceleration *)acceleration
{
self.delegate_->didAccelerate(acceleration);
}
- (void) dealloc
{
self.delegate_->AccelerometerDestroy();
[super dealloc];
}
@end

View File

@ -37,8 +37,7 @@ public:
static CCAccelerometer* sharedAccelerometer();
void removeDelegate(CCAccelerometerDelegate* pDelegate);
void addDelegate(CCAccelerometerDelegate* pDelegate);
void setDelegate(CCAccelerometerDelegate* pDelegate);
private:
static CCAccelerometer* m_spUIAccelerometer;

View File

@ -46,12 +46,7 @@ namespace cocos2d {
return m_spUIAccelerometer;
}
void CCAccelerometer::removeDelegate(CCAccelerometerDelegate* pDelegate)
{
[[AccelerometerDispatcher sharedAccelerometerDispather] removeDelegate:pDelegate];
}
void CCAccelerometer::addDelegate(CCAccelerometerDelegate* pDelegate)
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
{
[[AccelerometerDispatcher sharedAccelerometerDispather] addDelegate:pDelegate];
}

View File

@ -126,6 +126,18 @@ ccLanguageType CCApplication::getCurrentLanguage()
{
ret = kLanguageEnglish;
}
else if ([languageCode isEqualToString:@"fr"]){
ret = kLanguageFrench;
}
else if ([languageCode isEqualToString:@"it"]){
ret = kLanguageItalian;
}
else if ([languageCode isEqualToString:@"de"]){
ret = kLanguageGerman;
}
else if ([languageCode isEqualToString:@"es"]){
ret = kLanguageSpanish;
}
return ret;
}

View File

@ -237,15 +237,9 @@ static void static_addValueToCCDict(id key, id value, CCDictionary<std::string,
namespace cocos2d {
// record the resource path
static char s_pszResourcePath[MAX_PATH] = {0};
void CCFileUtils::setResourcePath(const char *pszResourcePath)
{
// NSAssert(pszResourcePath != NULL, "[FileUtils setResourcePath] -- wrong resource path");
// NSAssert(strlen(pszResourcePath) <= MAX_PATH, "[FileUtils setResourcePath] -- resource path too long");
strcpy(s_pszResourcePath, pszResourcePath);
assert(0);
}
int CCFileUtils::ccLoadFileIntoMemory(const char *filename, unsigned char **out)

View File

@ -328,6 +328,30 @@ static bool _isValidFontName(const char *fontName)
return ret;
}
static CGSize _caculateStringSizeWithFontOrZFont(NSString *str, id font, bool isZfont)
{
NSArray *listItems = [str componentsSeparatedByString: @"\n"];
CGSize dim;
for (NSString *s in listItems)
{
CGSize tmp;
if (isZfont)
{
[FontLabelStringDrawingHelper sizeWithZFont:str zfont:font];
}
else
{
tmp = [s sizeWithFont:font];
}
dim.width += tmp.width;
dim.height += tmp.height;
}
return dim;
}
static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo)
{
bool bRet = false;
@ -344,7 +368,7 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
font = [UIFont fontWithName:fntName size:nSize];
if (font)
{
dim = [str sizeWithFont:font];
dim = _caculateStringSizeWithFontOrZFont(str, font, false);
}
#if CC_FONT_LABEL_SUPPORT
@ -353,8 +377,8 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
font = [[FontManager sharedManager] zFontWithName:fntName pointSize:nSize];
if (font)
{
//dim = [str sizeWithZFont:font];
dim = [FontLabelStringDrawingHelper sizeWithZFont:str zfont:font];
//dim = [str sizeWithZFont:font];
dim =_caculateStringSizeWithFontOrZFont(str, font, true);
}
}
#endif // CC_FONT_LABEL_SUPPORT
@ -371,7 +395,7 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
if (font)
{
dim = [str sizeWithFont:font];
dim = _caculateStringSizeWithFontOrZFont(str, font, false);
}
}

View File

@ -34,9 +34,7 @@ public:
~CCAccelerometer();
static CCAccelerometer* sharedAccelerometer() { return NULL; }
void removeDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);}
void addDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);}
void setDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);}
};
}//namespace cocos2d

View File

@ -27,72 +27,13 @@ THE SOFTWARE.
#include "TCOM_Generic_Method_IIDs.h"
//Ö»ÄÜ°üº¬Ò»´Î
// Can only include once
#include "TCOM_Sensors_IIDs.h"
namespace cocos2d {
static CCAccelerometer s_Accelerometer;
//------------------------------------------------------------------
//
// CCAccelerometerHandler
//
//------------------------------------------------------------------
CCAccelerometerDelegate* CCAccelerometerHandler::getDelegate()
{
return m_pDelegate;
}
CCAccelerometerHandler::~CCAccelerometerHandler()
{
m_pDelegate->AccelerometerDestroy();
}
void CCAccelerometerHandler::setDelegate(CCAccelerometerDelegate *pDelegate)
{
if (pDelegate)
{
pDelegate->AccelerometerKeep();
}
if (m_pDelegate)
{
m_pDelegate->AccelerometerDestroy();
}
m_pDelegate = pDelegate;
}
bool CCAccelerometerHandler::initWithDelegate(CCAccelerometerDelegate *pDelegate)
{
assert(pDelegate != NULL);
m_pDelegate = pDelegate;
pDelegate->AccelerometerKeep();
return true;
}
CCAccelerometerHandler* CCAccelerometerHandler::handlerWithDelegate(CCAccelerometerDelegate *pDelegate)
{
CCAccelerometerHandler* pHandler = new CCAccelerometerHandler;
if (pHandler)
{
if (pHandler->initWithDelegate(pDelegate))
{
pHandler->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(pHandler);
}
}
return pHandler;
}
//------------------------------------------------------------------
//
// CCAccelerometer
@ -100,19 +41,19 @@ CCAccelerometerHandler* CCAccelerometerHandler::handlerWithDelegate(CCAccelerome
//------------------------------------------------------------------
CCAccelerometer::CCAccelerometer()
: m_pSensor(NULL)
, m_pDelegate(NULL)
{
m_pDelegates = new AccDelegateArray;
}
CCAccelerometer::~CCAccelerometer()
{
m_pDelegates->release();
if (m_pSensor)
{
m_pSensor->Release();
m_pSensor = NULL;
}
m_pDelegate = NULL;
}
CCAccelerometer* CCAccelerometer::sharedAccelerometer()
@ -120,92 +61,53 @@ CCAccelerometer* CCAccelerometer::sharedAccelerometer()
return &s_Accelerometer;
}
void CCAccelerometer::removeDelegate(CCAccelerometerDelegate* pDelegate)
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
{
CCAccelerometerHandler *pHandler;
CCMutableArray<CCAccelerometerHandler*>::CCMutableArrayIterator iter;
m_pDelegate = pDelegate;
if (pDelegate)
{
for (iter = m_pDelegates->begin(); iter != m_pDelegates->end(); ++iter)
{
pHandler = *iter;
if (pHandler && pHandler->getDelegate() == pDelegate)
{
m_pDelegates->removeObject(pHandler);
break;
}
}
}
if (m_pDelegate)
{
do
{
if (m_pSensor)
{
break;
}
if (0 == m_pDelegates->count())
{
m_pSensor->Release();
m_pSensor = NULL;
}
}
m_pSensor = TCOM_Sensors_DataType_Client::GetInstance();
void CCAccelerometer::addDelegate(CCAccelerometerDelegate* pDelegate)
{
CCAccelerometerHandler *pHandlerIter;
CCMutableArray<CCAccelerometerHandler*>::CCMutableArrayIterator iter;
if (m_pSensor)
{
m_pSensor->StartUp();
m_pSensor->SetDelay(TG3_SENSOR_DELAY_FASTEST);
if (pDelegate)
{
for (iter = m_pDelegates->begin(); iter != m_pDelegates->end(); ++iter)
{
pHandlerIter = *iter;
if (pHandlerIter && pHandlerIter->getDelegate() == pDelegate)
{
// this delegate have existed
return;
}
}
}
CCAccelerometerHandler* pHandler = CCAccelerometerHandler::handlerWithDelegate(pDelegate);
if (pHandler)
{
m_pDelegates->addObject(pHandler);
if (!m_pSensor)
{
m_pSensor = TCOM_Sensors_DataType_Client::GetInstance();
if (m_pSensor)
{
m_pSensor->StartUp();
m_pSensor->SetDelay(TG3_SENSOR_DELAY_FASTEST);
TApplication* pApp = TApplication::GetCurrentApplication();
TWindow* pWnd = pApp->GetActiveWindow();
m_pSensor->SetWindowCtrlId(pWnd->GetWindowHwndId(), 0);
m_pSensor->Activate(TG3_SENSOR_TYPE_ACCELEROMETER, TRUE);
}
else
{
CCLOG("cocos2d: The Accelerometer Sensor Open failed");
}
}
}
TApplication* pApp = TApplication::GetCurrentApplication();
TWindow* pWnd = pApp->GetActiveWindow();
m_pSensor->SetWindowCtrlId(pWnd->GetWindowHwndId(), 0);
m_pSensor->Activate(TG3_SENSOR_TYPE_ACCELEROMETER, TRUE);
}
else
{
CCLOG("cocos2d: The Accelerometer Sensor Open failed");
}
} while (0);
}
else
{
if (m_pSensor)
{
m_pSensor->Release();
m_pSensor = NULL;
}
}
}
void CCAccelerometer::didAccelerate(CCAcceleration* pAccelerationValue)
{
CCAccelerometerHandler *pHandler;
CCAccelerometerDelegate *pDelegate;
CCMutableArray<CCAccelerometerHandler*>::CCMutableArrayIterator iter;
if (m_pDelegates->count() > 0)
{
for (iter = m_pDelegates->begin(); iter != m_pDelegates->end(); ++iter)
{
pHandler = *iter;
pDelegate = pHandler->getDelegate();
pDelegate->didAccelerate(pAccelerationValue);
}
}
if (m_pDelegate)
{
m_pDelegate->didAccelerate(pAccelerationValue);
}
}
}//namespace cocos2d

View File

@ -27,37 +27,11 @@ THE SOFTWARE.
#include "CCAccelerometerDelegate.h"
#include "TG3.h"
#include "CCMutableArray.h"
#include "CCCommon.h"
#include "TCOM_Sensors_Interface.h"
namespace cocos2d {
/**
@brief
CCAccelerometerHandler
Object than contains the CCAccelerometerDelegate.
*/
class CC_DLL CCAccelerometerHandler : public CCObject
{
public:
virtual ~CCAccelerometerHandler(void);
/** delegate */
CCAccelerometerDelegate* getDelegate();
void setDelegate(CCAccelerometerDelegate *pDelegate);
/** initializes a CCAccelerometerHandler with a delegate */
virtual bool initWithDelegate(CCAccelerometerDelegate *pDelegate);
public:
/** allocates a AccelerometerHandler with a delegate */
static CCAccelerometerHandler* handlerWithDelegate(CCAccelerometerDelegate *pDelegate);
protected:
CCAccelerometerDelegate* m_pDelegate;
};
/**
@brief
The CCAccelerometer class lets you register to receive
@ -77,12 +51,7 @@ public:
/**
@brief add delegate to concern accelerometer sensor
*/
void addDelegate(CCAccelerometerDelegate* pDelegate);
/**
@brief remove the delegate from the delegates who concern Accelerometer Sensor
*/
void removeDelegate(CCAccelerometerDelegate* pDelegate);
void setDelegate(CCAccelerometerDelegate* pDelegate);
/**
@brief call delegates' didAccelerate function
@ -90,9 +59,7 @@ public:
void didAccelerate(CCAcceleration* pAccelerationValue);
protected:
typedef CCMutableArray<CCAccelerometerHandler*> AccDelegateArray;
AccDelegateArray* m_pDelegates;
CCAccelerometerDelegate* m_pDelegate;
TCOM_Sensors_DataType_Client* m_pSensor;
};

View File

@ -323,7 +323,6 @@ CCSprite* CCSprite::initWithCGImage(CGImageRef pImage, const char *pszKey)
CCSprite::CCSprite()
: m_pobTexture(NULL)
{
init();
}
CCSprite::~CCSprite(void)

View File

@ -32,7 +32,7 @@ namespace cocos2d
struct CCZHeader {
unsigned char sig[4]; // signature. Should be 'CCZ!' 4 bytes
unsigned short compression_type; // should 0
unsigned char version; // should be 2 (although version type==1 is also supported)
unsigned short version; // should be 2 (although version type==1 is also supported)
unsigned int reserved; // Reserverd for users.
unsigned int len; // size of the uncompressed file
};
@ -47,14 +47,14 @@ namespace cocos2d
class ZipUtils
{
public:
/**
* Inflates either zlib or gzip deflated memory. The inflated memory is
* expected to be freed by the caller.
*
* It will allocate 256k for the destination buffer. If it is not enought it will multiply the previous buffer size per 2, until there is enough memory.
* @returns the length of the deflated buffer
*
@since v0.8.1
/**
* Inflates either zlib or gzip deflated memory. The inflated memory is
* expected to be freed by the caller.
*
* It will allocate 256k for the destination buffer. If it is not enought it will multiply the previous buffer size per 2, until there is enough memory.
* @returns the length of the deflated buffer
*
@since v0.8.1
*/
static int ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out);

View File

@ -364,7 +364,7 @@ void CCTextureAtlas::drawQuads()
void CCTextureAtlas::drawNumberOfQuads(unsigned int n)
{
this->drawNumberOfQuads(m_uTotalQuads, 0);
this->drawNumberOfQuads(n, 0);
}
void CCTextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)

View File

@ -99,7 +99,6 @@ CCLuaScriptModule::~CCLuaScriptModule()
lua_close( d_state );
}
s_luaScriptModule = NULL;
}
@ -125,13 +124,14 @@ bool CCLuaScriptModule::addSearchPath(const std::string& path)
bool CCLuaScriptModule::executeScriptFile(const std::string& filename)
{
int nRet = luaL_dofile(d_state,filename.c_str());
if (nRet != 0)
{
CCLog("executeScriptFile Error nRet = %d", nRet);
{
// print the error msg
const char* strErrMsg = lua_tostring(d_state, -1);
CCLog("%s", strErrMsg);
CCLog("%s", lua_tostring(d_state, -1));
// pop the error code
lua_pop(d_state, 1);
return false;
}
@ -181,8 +181,6 @@ int CCLuaScriptModule::executeScriptGlobal(const std::string& function_name)
// return it
return ret;
}
@ -232,9 +230,8 @@ bool CCLuaScriptModule::executeSchedule(const std::string& handler_name, ccTime
}
// return it
return true;
}
bool CCLuaScriptModule::executeCallFunc(const std::string& handler_name)
{
@ -270,8 +267,8 @@ bool CCLuaScriptModule::executeCallFunc(const std::string& handler_name)
}
// return it
return true;
}
bool CCLuaScriptModule::executeCallFuncN(const std::string& handler_name, CCNode* pNode)
{
@ -386,8 +383,8 @@ bool CCLuaScriptModule::executeCallFuncND(const std::string& handler_name, CCNod
}
// return it
return true;
}
bool CCLuaScriptModule::executeMenuHandler(const std::string& handler_name, CCObject* pobj)
{
@ -423,7 +420,6 @@ bool CCLuaScriptModule::executeMenuHandler(const std::string& handler_name, CCOb
}
// return it
return true;
}
bool CCLuaScriptModule::executeTouchesEvent(const std::string& handler_name, CCSet *pobj)
@ -508,9 +504,8 @@ bool CCLuaScriptModule::executeTouch(const std::string& handler_name, CCTouch *p
}
// return it
return true;
}
bool CCLuaScriptModule::executeEventHandler(const std::string& handler_name, CCEvent* pEvent)
{
@ -547,7 +542,6 @@ bool CCLuaScriptModule::executeEventHandler(const std::string& handler_name, CCE
}
// return it
return true;
}
bool CCLuaScriptModule::executeListItem(const std::string& handler_name, int index, CCObject* pobj)
@ -587,7 +581,6 @@ bool CCLuaScriptModule::executeListItem(const std::string& handler_name, int ind
}
// return it
return true;
}
/*************************************************************************
@ -599,9 +592,12 @@ bool CCLuaScriptModule::executeString(const std::string& str)
int error = luaL_dostring(d_state, str.c_str());
// handle errors
if ( error )
if (error)
{
CCLog("executeString %d", error);
// print error message and pop it
CCLog("%s", lua_tostring(d_state, -1));
lua_pop(d_state, 1);
return false;
}

View File

@ -3,7 +3,7 @@ ANDROID_NDK_ROOT=__ndkroot__
COCOS2DX_ROOT=__cocos2dxroot__
GAME_ROOT=$COCOS2DX_ROOT/__projectname__
GAME_ANDROID_ROOT=$GAME_ROOT/android
RESOURCE_ROOT=$GAME_ROOT/Resource
RESOURCE_ROOT=$GAME_ROOT/Resources
# make sure assets is exist
if [ -d $GAME_ANDROID_ROOT/assets ]; then

View File

@ -120,7 +120,8 @@ OBJECTS = \
$(OBJECTS_DIR)/TransitionsTest.o \
$(OBJECTS_DIR)/UserDefaultTest.o \
$(OBJECTS_DIR)/ZwoptexTest.o \
$(OBJECTS_DIR)/FontTest.o
$(OBJECTS_DIR)/FontTest.o \
$(OBJECTS_DIR)/CurrentLanguageTest.o
ADD_OBJECTS +=
@ -394,3 +395,6 @@ $(OBJECTS_DIR)/ZwoptexTest.o : ../tests/ZwoptexTest/ZwoptexTest.cpp
$(OBJECTS_DIR)/FontTest.o : ../tests/FontTest/FontTest.cpp
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/FontTest.o ../tests/FontTest/FontTest.cpp
$(OBJECTS_DIR)/CurrentLanguageTest.o : ../tests/CurrentLanguageTest/CurrentLanguageTest.cpp
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CurrentLanguageTest.o ../tests/CurrentLanguageTest/CurrentLanguageTest.cpp

View File

@ -68,8 +68,6 @@ namespace cocos2d{
void keep(void);
void didAccelerate(CCAcceleration* pAccelerationValue) {}
void AccelerometerDestroy(void);
void AccelerometerKeep(void);
void KeypadDestroy();
void KeypadKeep();