Merge branch 'gles20' of http://github.com/cocos2d/cocos2d-x into gles20

This commit is contained in:
Walzer 2012-05-05 10:07:21 +08:00
commit 6b374881f0
13 changed files with 226 additions and 209 deletions

View File

@ -1,23 +1,9 @@
#include "cocos2d.h" #include "cocos2d.h"
#include "AppDelegate.h" #include "AppDelegate.h"
#include "SimpleAudioEngine.h" #include "SimpleAudioEngine.h"
#include "CCScriptSupport.h" #include "CCScriptSupport.h"
#include "CCLuaEngine.h" #include "CCLuaEngine.h"
#define IPAD 0
#if IPAD
#define CC_WIDTH 1024
#define CC_HEIGHT 768
#elif IPHONE_4
#define CC_WIDTH 960
#define CC_HEIGHT 640
#else
#define CC_WIDTH 480
#define CC_HEIGHT 320
#endif
USING_NS_CC; USING_NS_CC;
using namespace CocosDenshion; using namespace CocosDenshion;
@ -56,23 +42,12 @@ bool AppDelegate::applicationDidFinishLaunching()
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
unsigned long size; CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua");
char *pFileContent = (char*)CCFileUtils::getFileData("hello.lua", "r", &size); if (pstrFileContent)
if (pFileContent)
{ {
// copy the file contents and add '\0' at the end, or the lua parser can not parse it pEngine->executeString(pstrFileContent->getCString());
char *pCodes = new char[size + 1];
pCodes[size] = '\0';
memcpy(pCodes, pFileContent, size);
delete[] pFileContent;
pEngine->executeString(pCodes);
delete []pCodes;
} }
#endif #else
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua");
pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
pEngine->executeScriptFile(path.c_str()); pEngine->executeScriptFile(path.c_str());
@ -85,16 +60,12 @@ bool AppDelegate::applicationDidFinishLaunching()
void AppDelegate::applicationDidEnterBackground() void AppDelegate::applicationDidEnterBackground()
{ {
CCDirector::sharedDirector()->pause(); CCDirector::sharedDirector()->pause();
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
} }
// this function will be called when the app is active again // this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() void AppDelegate::applicationWillEnterForeground()
{ {
CCDirector::sharedDirector()->resume(); CCDirector::sharedDirector()->resume();
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
} }

View File

@ -1,6 +1,6 @@
# set params # set params
NDK_ROOT_LOCAL=/cygdrive/d/programe/android/ndk/android-ndk-r7b NDK_ROOT_LOCAL=/cygdrive/e/android/android-ndk-r8
COCOS2DX_ROOT_LOCAL=/cygdrive/e/cocos2d-x COCOS2DX_ROOT_LOCAL=/cygdrive/f/Project/dumganhar/cocos2d-x
buildexternalsfromsource= buildexternalsfromsource=

View File

@ -1,2 +0,0 @@
# Project target.
target=android-10

View File

@ -34,6 +34,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
} }
else else
{ {
ccDrawInit();
ccGLInvalidateStateCache();
CCShaderCache::sharedShaderCache()->reloadDefaultShaders(); CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
CCTextureCache::reloadAllTextures(); CCTextureCache::reloadAllTextures();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);

View File

@ -8,4 +8,4 @@
# project structure. # project structure.
# Project target. # Project target.
target=android-8 target=android-10

View File

@ -234,6 +234,11 @@ void CCEaseIn::update(ccTime time)
m_pOther->update(powf(time, m_fRate)); m_pOther->update(powf(time, m_fRate));
} }
CCActionInterval* CCEaseIn::reverse(void)
{
return CCEaseIn::actionWithAction(m_pOther->reverse(), 1 / m_fRate);
}
// //
// EaseOut // EaseOut
// //
@ -281,6 +286,11 @@ void CCEaseOut::update(ccTime time)
m_pOther->update(powf(time, 1 / m_fRate)); m_pOther->update(powf(time, 1 / m_fRate));
} }
CCActionInterval* CCEaseOut::reverse()
{
return CCEaseOut::actionWithAction(m_pOther->reverse(), 1 / m_fRate);
}
// //
// EaseInOut // EaseInOut
// //
@ -325,14 +335,6 @@ CCObject* CCEaseInOut::copyWithZone(CCZone *pZone)
void CCEaseInOut::update(ccTime time) void CCEaseInOut::update(ccTime time)
{ {
int sign = 1;
int r = (int) m_fRate;
if (r % 2 == 0)
{
sign = -1;
}
time *= 2; time *= 2;
if (time < 1) if (time < 1)
{ {
@ -340,7 +342,7 @@ void CCEaseInOut::update(ccTime time)
} }
else else
{ {
m_pOther->update(sign * 0.5f * (powf(time - 2, m_fRate) + sign * 2)); m_pOther->update(1.0f - 0.5f * powf(2-time, m_fRate));
} }
} }
@ -505,12 +507,17 @@ void CCEaseExponentialInOut::update(ccTime time)
} }
else else
{ {
time = 0.5f * (-powf(2, 10 * (time - 1)) + 2); time = 0.5f * (-powf(2, -10 * (time - 1)) + 2);
} }
m_pOther->update(time); m_pOther->update(time);
} }
CCActionInterval* CCEaseExponentialInOut::reverse()
{
return CCEaseExponentialInOut::actionWithAction(m_pOther->reverse());
}
// //
// EaseSineIn // EaseSineIn
// //
@ -662,6 +669,11 @@ void CCEaseSineInOut::update(ccTime time)
m_pOther->update(-0.5f * (cosf((float)M_PI * time) - 1)); m_pOther->update(-0.5f * (cosf((float)M_PI * time) - 1));
} }
CCActionInterval* CCEaseSineInOut::reverse()
{
return CCEaseSineInOut::actionWithAction(m_pOther->reverse());
}
// //
// EaseElastic // EaseElastic
// //
@ -740,7 +752,7 @@ CCObject* CCEaseElastic::copyWithZone(CCZone *pZone)
CCActionInterval* CCEaseElastic::reverse(void) CCActionInterval* CCEaseElastic::reverse(void)
{ {
CCAssert(0, ""); CCAssert(0, "Override me");
return NULL; return NULL;
} }
@ -1002,7 +1014,7 @@ void CCEaseElasticInOut::update(ccTime time)
CCActionInterval* CCEaseElasticInOut::reverse(void) CCActionInterval* CCEaseElasticInOut::reverse(void)
{ {
return CCEaseInOut::actionWithAction(m_pOther->reverse(), m_fPeriod); return CCEaseElasticInOut::actionWithAction(m_pOther->reverse(), m_fPeriod);
} }
// //
@ -1068,6 +1080,11 @@ ccTime CCEaseBounce::bounceTime(ccTime time)
return 7.5625f * time * time + 0.984375f; return 7.5625f * time * time + 0.984375f;
} }
CCActionInterval* CCEaseBounce::reverse()
{
return CCEaseBounce::actionWithAction(m_pOther->reverse());
}
// //
// EaseBounceIn // EaseBounceIn
// //
@ -1232,6 +1249,11 @@ void CCEaseBounceInOut::update(ccTime time)
m_pOther->update(newT); m_pOther->update(newT);
} }
CCActionInterval* CCEaseBounceInOut::reverse()
{
return CCEaseBounceInOut::actionWithAction(m_pOther->reverse());
}
// //
// EaseBackIn // EaseBackIn
// //
@ -1398,4 +1420,9 @@ void CCEaseBackInOut::update(ccTime time)
} }
} }
CCActionInterval* CCEaseBackInOut::reverse()
{
return CCEaseBackInOut::actionWithAction(m_pOther->reverse());
}
NS_CC_END NS_CC_END

View File

@ -92,6 +92,7 @@ class CC_DLL CCEaseIn : public CCEaseRateAction
{ {
public: public:
virtual void update(ccTime time); virtual void update(ccTime time);
virtual CCActionInterval* reverse(void);
virtual CCObject* copyWithZone(CCZone* pZone); virtual CCObject* copyWithZone(CCZone* pZone);
public: public:
/** Creates the action with the inner action and the rate parameter */ /** Creates the action with the inner action and the rate parameter */
@ -105,6 +106,7 @@ class CC_DLL CCEaseOut : public CCEaseRateAction
{ {
public: public:
virtual void update(ccTime time); virtual void update(ccTime time);
virtual CCActionInterval* reverse();
virtual CCObject* copyWithZone(CCZone* pZone); virtual CCObject* copyWithZone(CCZone* pZone);
public: public:
@ -166,6 +168,7 @@ class CC_DLL CCEaseExponentialInOut : public CCActionEase
public: public:
virtual void update(ccTime time); virtual void update(ccTime time);
virtual CCObject* copyWithZone(CCZone* pZone); virtual CCObject* copyWithZone(CCZone* pZone);
virtual CCActionInterval* reverse();
public: public:
/** creates the action */ /** creates the action */
@ -211,6 +214,7 @@ class CC_DLL CCEaseSineInOut : public CCActionEase
public: public:
virtual void update(ccTime time); virtual void update(ccTime time);
virtual CCObject* copyWithZone(CCZone* pZone); virtual CCObject* copyWithZone(CCZone* pZone);
virtual CCActionInterval* reverse();
public: public:
/** creates the action */ /** creates the action */
@ -313,6 +317,7 @@ class CC_DLL CCEaseBounce : public CCActionEase
public: public:
ccTime bounceTime(ccTime time); ccTime bounceTime(ccTime time);
virtual CCObject* copyWithZone(CCZone* pZone); virtual CCObject* copyWithZone(CCZone* pZone);
virtual CCActionInterval* reverse();
public: public:
/** creates the action */ /** creates the action */
@ -363,6 +368,7 @@ class CC_DLL CCEaseBounceInOut : public CCEaseBounce
public: public:
virtual void update(ccTime time); virtual void update(ccTime time);
virtual CCObject* copyWithZone(CCZone* pZone); virtual CCObject* copyWithZone(CCZone* pZone);
virtual CCActionInterval* reverse();
public: public:
/** creates the action */ /** creates the action */
@ -413,6 +419,7 @@ class CC_DLL CCEaseBackInOut : public CCActionEase
public: public:
virtual void update(ccTime time); virtual void update(ccTime time);
virtual CCObject* copyWithZone(CCZone* pZone); virtual CCObject* copyWithZone(CCZone* pZone);
virtual CCActionInterval* reverse();
public: public:
/** creates the action */ /** creates the action */

View File

@ -76,9 +76,6 @@ CCObject* CCActionInterval::copyWithZone(CCZone *pZone)
} }
else else
{ {
// action's base class , must be called using __super::copyWithZone(), after overriding from derived class
CCAssert(0, "");
pCopy = new CCActionInterval(); pCopy = new CCActionInterval();
pZone = pNewZone = new CCZone(pCopy); pZone = pNewZone = new CCZone(pCopy);
} }
@ -110,8 +107,12 @@ void CCActionInterval::step(ccTime dt)
m_elapsed += dt; m_elapsed += dt;
} }
// update(min(1, m_elapsed/m_fDuration)); this->update(MAX (0, // needed for rewind. elapsed could be negative
update(1 > m_elapsed/m_fDuration ? m_elapsed/m_fDuration : 1); MIN(1, m_elapsed /
MAX(m_fDuration, FLT_EPSILON) // division by 0
)
)
);
} }
void CCActionInterval::setAmplitudeRate(CCFloat amp) void CCActionInterval::setAmplitudeRate(CCFloat amp)
@ -138,13 +139,7 @@ void CCActionInterval::startWithTarget(CCNode *pTarget)
CCActionInterval* CCActionInterval::reverse(void) CCActionInterval* CCActionInterval::reverse(void)
{ {
/* CCAssert(false, "CCIntervalAction: reverse not implemented.");
NSException* myException = [NSException
exceptionWithName:@"ReverseActionNotImplemented"
reason:@"Reverse Action not implemented"
userInfo:nil];
@throw myException;
*/
return NULL; return NULL;
} }

View File

@ -46,23 +46,12 @@ bool AppDelegate::applicationDidFinishLaunching()
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
unsigned long size; CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua");
char *pFileContent = (char*)CCFileUtils::getFileData("hello.lua", "r", &size); if (pstrFileContent)
if (pFileContent)
{ {
// copy the file contents and add '\0' at the end, or the lua parser can not parse it pEngine->executeString(pstrFileContent->getCString());
char *pCodes = new char[size + 1];
pCodes[size] = '\0';
memcpy(pCodes, pFileContent, size);
delete[] pFileContent;
pEngine->executeString(pCodes);
delete []pCodes;
} }
#endif #else
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua");
pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
pEngine->executeScriptFile(path.c_str()); pEngine->executeScriptFile(path.c_str());

View File

@ -1,23 +1,9 @@
#include "cocos2d.h" #include "cocos2d.h"
#include "AppDelegate.h" #include "AppDelegate.h"
#include "SimpleAudioEngine.h" #include "SimpleAudioEngine.h"
#include "CCScriptSupport.h" #include "CCScriptSupport.h"
#include "CCLuaEngine.h" #include "CCLuaEngine.h"
#define IPAD 0
#if IPAD
#define CC_WIDTH 1024
#define CC_HEIGHT 768
#elif IPHONE_4
#define CC_WIDTH 960
#define CC_HEIGHT 640
#else
#define CC_WIDTH 480
#define CC_HEIGHT 320
#endif
USING_NS_CC; USING_NS_CC;
using namespace std; using namespace std;
using namespace CocosDenshion; using namespace CocosDenshion;
@ -57,23 +43,12 @@ bool AppDelegate::applicationDidFinishLaunching()
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
unsigned long size; CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua");
char *pFileContent = (char*)CCFileUtils::getFileData("hello.lua", "r", &size); if (pstrFileContent)
if (pFileContent)
{ {
// copy the file contents and add '\0' at the end, or the lua parser can not parse it pEngine->executeString(pstrFileContent->getCString());
char *pCodes = new char[size + 1];
pCodes[size] = '\0';
memcpy(pCodes, pFileContent, size);
delete[] pFileContent;
pEngine->executeString(pCodes);
delete []pCodes;
} }
#endif #else
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); string path = CCFileUtils::fullPathFromRelativePath("hello.lua");
pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
pEngine->executeScriptFile(path.c_str()); pEngine->executeScriptFile(path.c_str());

View File

@ -16,36 +16,39 @@ CCLayer* restartEaseAction();
// SpriteEase // SpriteEase
// //
//------------------------------------------------------------------ //------------------------------------------------------------------
#define CCCA(x) (x->copy()->autorelease())
void SpriteEase::onEnter() void SpriteEase::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0) ); CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130,0));
CCActionInterval* move_back = move->reverse(); CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = (CCActionInterval*)CCEaseIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 2.5f); CCActionInterval* move_ease_in = CCEaseIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 2.5f);
CCActionInterval* move_ease_in_back = move_ease_in->reverse(); CCActionInterval* move_ease_in_back = move_ease_in->reverse();
CCActionInterval* move_ease_out = CCEaseOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 2.5f); CCActionInterval* move_ease_out = CCEaseOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 2.5f);
CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq1 = CCSequence::actions(move, move_back, NULL); CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, move_ease_in_back, NULL); CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, move_ease_out_back, NULL); CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
CCAction *a2 = m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1) ); CCAction *a2 = m_grossini->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
a2->setTag(1); a2->setTag(1);
CCAction *a1 = m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) ); CCAction *a1 = m_tamara->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
a1->setTag(1); a1->setTag(1);
CCAction *a = m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) ); CCAction *a = m_kathia->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
a->setTag(1); a->setTag(1);
schedule(schedule_selector(SpriteEase::testStopAction), 6); schedule(schedule_selector(SpriteEase::testStopAction), 6.25f);
} }
void SpriteEase::testStopAction(ccTime dt) void SpriteEase::testStopAction(ccTime dt)
@ -72,7 +75,9 @@ void SpriteEaseInOut::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0)); CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130,0));
// id move_back = move->reverse(); // id move_back = move->reverse();
CCActionInterval* move_ease_inout1 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.65f); CCActionInterval* move_ease_inout1 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.65f);
@ -84,14 +89,15 @@ void SpriteEaseInOut::onEnter()
CCActionInterval* move_ease_inout3 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 1.0f); CCActionInterval* move_ease_inout3 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 1.0f);
CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse(); CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse();
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq1 = CCSequence::actions( move_ease_inout1, move_ease_inout_back1, NULL); CCFiniteTimeAction* seq1 = CCSequence::actions( move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_inout2, move_ease_inout_back2, NULL); CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_inout3, move_ease_inout_back3, NULL); CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_inout3, CCCA(delay), move_ease_inout_back3, CCCA(delay), NULL);
m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1) ); m_tamara->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) ); m_kathia->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) ); m_grossini->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
} }
@ -110,7 +116,9 @@ void SpriteEaseExponential::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0)); CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130,0));
CCActionInterval* move_back = move->reverse(); CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = CCEaseExponentialIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_in = CCEaseExponentialIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
@ -119,15 +127,16 @@ void SpriteEaseExponential::onEnter()
CCActionInterval* move_ease_out = CCEaseExponentialOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_out = CCEaseExponentialOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL); CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL); CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL); CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1) ); m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) ); m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) ); m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
} }
@ -145,14 +154,18 @@ void SpriteEaseExponentialInOut::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0)); CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0));
CCActionInterval* move_back = move->reverse(); CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease = CCEaseExponentialInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease = CCEaseExponentialInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_back = move_ease->reverse(); //--> reverse() CCActionInterval* move_ease_back = move_ease->reverse(); //--> reverse()
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL); CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);
CCFiniteTimeAction* seq1 = CCSequence::actions( move, delay, move_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, delay, move_ease_back, CCCA(delay), NULL);
this->positionForTwo(); this->positionForTwo();
@ -176,7 +189,9 @@ void SpriteEaseSine::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0)); CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0));
CCActionInterval* move_back = move->reverse(); CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = CCEaseSineIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_in = CCEaseSineIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
@ -185,10 +200,11 @@ void SpriteEaseSine::onEnter()
CCActionInterval* move_ease_out = CCEaseSineOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_out = CCEaseSineOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL); CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL); CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL); CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
@ -212,14 +228,18 @@ void SpriteEaseSineInOut::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0)); CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130,0));
CCActionInterval* move_back = move->reverse(); CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease = CCEaseSineInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease = CCEaseSineInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_back = move_ease->reverse(); CCActionInterval* move_ease_back = move_ease->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL); CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);
CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL);
this->positionForTwo(); this->positionForTwo();
@ -241,7 +261,10 @@ std::string SpriteEaseSineInOut::title()
void SpriteEaseElastic::onEnter() void SpriteEaseElastic::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0));
CCActionInterval* move_back = move->reverse(); CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = CCEaseElasticIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_in = CCEaseElasticIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
@ -250,9 +273,11 @@ void SpriteEaseElastic::onEnter()
CCActionInterval* move_ease_out = CCEaseElasticOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_out = CCEaseElasticOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL); CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL); CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
@ -275,7 +300,9 @@ void SpriteEaseElasticInOut::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0)); CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0));
CCActionInterval* move_ease_inout1 = CCEaseElasticInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.3f); CCActionInterval* move_ease_inout1 = CCEaseElasticInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.3f);
CCActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse(); CCActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse();
@ -286,10 +313,11 @@ void SpriteEaseElasticInOut::onEnter()
CCActionInterval* move_ease_inout3 = CCEaseElasticInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.6f); CCActionInterval* move_ease_inout3 = CCEaseElasticInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.6f);
CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse(); CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse();
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq1 = CCSequence::actions( move_ease_inout1, move_ease_inout_back1, NULL); CCFiniteTimeAction* seq1 = CCSequence::actions(move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_inout2, move_ease_inout_back2, NULL); CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_inout3, move_ease_inout_back3, NULL); CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_inout3, CCCA(delay), move_ease_inout_back3, CCCA(delay), NULL);
m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
@ -312,7 +340,10 @@ std::string SpriteEaseElasticInOut::title()
void SpriteEaseBounce::onEnter() void SpriteEaseBounce::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0));
CCActionInterval* move_back = move->reverse(); CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = CCEaseBounceIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_in = CCEaseBounceIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
@ -321,9 +352,11 @@ void SpriteEaseBounce::onEnter()
CCActionInterval* move_ease_out = CCEaseBounceOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_out = CCEaseBounceOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL); CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL); CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
@ -347,14 +380,18 @@ void SpriteEaseBounceInOut::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0)); CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0));
CCActionInterval* move_back = move->reverse(); CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease = CCEaseBounceInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease = CCEaseBounceInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_back = move_ease->reverse(); CCActionInterval* move_ease_back = move_ease->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL); CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);
CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL);
this->positionForTwo(); this->positionForTwo();
@ -377,22 +414,27 @@ std::string SpriteEaseBounceInOut::title()
void SpriteEaseBack::onEnter() void SpriteEaseBack::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0));
CCActionInterval* move_back = move->reverse(); CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = CCEaseBackIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_in = CCEaseBackIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()));
CCActionInterval* move_ease_in_back = move_ease_in->reverse(); CCActionInterval* move_ease_in_back = move_ease_in->reverse();
CCActionInterval* move_ease_out = CCEaseBackOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_out = CCEaseBackOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()));
CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL); CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL);
m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL);
m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3)); CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
m_grossini->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
m_tamara->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
m_kathia->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
} }
@ -410,14 +452,19 @@ std::string SpriteEaseBack::title()
void SpriteEaseBackInOut::onEnter() void SpriteEaseBackInOut::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0));
CCActionInterval* move_back = move->reverse(); CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease = CCEaseBackInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease = CCEaseBackInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_back = move_ease->reverse(); CCActionInterval* move_ease_back = move_ease->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL); CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);
CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL);
this->positionForTwo(); this->positionForTwo();
@ -441,8 +488,10 @@ void SpeedTest::onEnter()
{ {
EaseSpriteDemo::onEnter(); EaseSpriteDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
// rotate and jump // rotate and jump
CCActionInterval *jump1 = CCJumpBy::actionWithDuration(4, CCPointMake(-400,0), 100, 4); CCActionInterval *jump1 = CCJumpBy::actionWithDuration(4, CCPointMake(-s.width+80, 0), 100, 4);
CCActionInterval *jump2 = jump1->reverse(); CCActionInterval *jump2 = jump1->reverse();
CCActionInterval *rot1 = CCRotateBy::actionWithDuration(4, 360*2); CCActionInterval *rot1 = CCRotateBy::actionWithDuration(4, 360*2);
CCActionInterval *rot2 = rot1->reverse(); CCActionInterval *rot2 = rot1->reverse();
@ -459,9 +508,9 @@ void SpeedTest::onEnter()
action2->setTag(kTagAction1); action2->setTag(kTagAction1);
action3->setTag(kTagAction1); action3->setTag(kTagAction1);
m_grossini->runAction( action2 ); m_grossini->runAction(action2);
m_tamara->runAction( action3 ); m_tamara->runAction(action3);
m_kathia->runAction( action ); m_kathia->runAction(action);
this->schedule(schedule_selector(SpeedTest::altertime), 1.0f);//:@selector(altertime:) interval:1.0f]; this->schedule(schedule_selector(SpeedTest::altertime), 1.0f);//:@selector(altertime:) interval:1.0f];
} }

View File

@ -26,6 +26,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
} }
else else
{ {
ccDrawInit();
ccGLInvalidateStateCache();
CCShaderCache::sharedShaderCache()->reloadDefaultShaders(); CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
CCTextureCache::reloadAllTextures(); CCTextureCache::reloadAllTextures();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);