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 "AppDelegate.h"
#include "SimpleAudioEngine.h"
#include "CCScriptSupport.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 namespace CocosDenshion;
@ -55,24 +41,13 @@ bool AppDelegate::applicationDidFinishLaunching()
CCScriptEngineProtocol* pEngine = CCLuaEngine::engine();
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
unsigned long size;
char *pFileContent = (char*)CCFileUtils::getFileData("hello.lua", "r", &size);
if (pFileContent)
{
// copy the file contents and add '\0' at the end, or the lua parser can not parse it
char *pCodes = new char[size + 1];
pCodes[size] = '\0';
memcpy(pCodes, pFileContent, size);
delete[] pFileContent;
pEngine->executeString(pCodes);
delete []pCodes;
}
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua");
if (pstrFileContent)
{
pEngine->executeString(pstrFileContent->getCString());
}
#else
std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua");
pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
pEngine->executeScriptFile(path.c_str());
@ -85,16 +60,12 @@ bool AppDelegate::applicationDidFinishLaunching()
void AppDelegate::applicationDidEnterBackground()
{
CCDirector::sharedDirector()->pause();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

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

View File

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

View File

@ -1,26 +1,26 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package org.cocos2dx.hellolua;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int test_demo_gl_surfaceview=0x7f050001;
public static final int textField=0x7f050000;
}
public static final class layout {
public static final int game_demo=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040000;
}
}
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package org.cocos2dx.hellolua;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int test_demo_gl_surfaceview=0x7f050001;
public static final int textField=0x7f050000;
}
public static final class layout {
public static final int game_demo=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040000;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,23 +1,9 @@
#include "cocos2d.h"
#include "AppDelegate.h"
#include "SimpleAudioEngine.h"
#include "CCScriptSupport.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 namespace std;
using namespace CocosDenshion;
@ -56,24 +42,13 @@ bool AppDelegate::applicationDidFinishLaunching()
CCScriptEngineProtocol* pEngine = CCLuaEngine::engine();
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
unsigned long size;
char *pFileContent = (char*)CCFileUtils::getFileData("hello.lua", "r", &size);
if (pFileContent)
{
// copy the file contents and add '\0' at the end, or the lua parser can not parse it
char *pCodes = new char[size + 1];
pCodes[size] = '\0';
memcpy(pCodes, pFileContent, size);
delete[] pFileContent;
pEngine->executeString(pCodes);
delete []pCodes;
}
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua");
if (pstrFileContent)
{
pEngine->executeString(pstrFileContent->getCString());
}
#else
string path = CCFileUtils::fullPathFromRelativePath("hello.lua");
pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
pEngine->executeScriptFile(path.c_str());

View File

@ -16,36 +16,39 @@ CCLayer* restartEaseAction();
// SpriteEase
//
//------------------------------------------------------------------
#define CCCA(x) (x->copy()->autorelease())
void SpriteEase::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_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_out = CCEaseOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 2.5f);
CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq1 = CCSequence::actions(move, move_back, NULL);
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);
CCAction *a2 = m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1) );
CCAction *a2 = m_grossini->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
a2->setTag(1);
CCAction *a1 = m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) );
CCAction *a1 = m_tamara->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
a1->setTag(1);
CCAction *a = m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) );
CCAction *a = m_kathia->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
a->setTag(1);
schedule(schedule_selector(SpriteEase::testStopAction), 6);
schedule(schedule_selector(SpriteEase::testStopAction), 6.25f);
}
void SpriteEase::testStopAction(ccTime dt)
@ -71,8 +74,10 @@ std::string SpriteEase::title()
void SpriteEaseInOut::onEnter()
{
EaseSpriteDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130,0));
// id move_back = move->reverse();
CCActionInterval* move_ease_inout1 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.65f);
@ -83,15 +88,16 @@ void SpriteEaseInOut::onEnter()
CCActionInterval* move_ease_inout3 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 1.0f);
CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move_ease_inout1, move_ease_inout_back1, NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_inout2, move_ease_inout_back2, NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_inout3, move_ease_inout_back3, NULL);
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq1 = CCSequence::actions( move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), 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_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) );
m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) );
m_tamara->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
m_kathia->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
m_grossini->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
}
@ -109,8 +115,10 @@ std::string SpriteEaseInOut::title()
void SpriteEaseExponential::onEnter()
{
EaseSpriteDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130,0));
CCActionInterval* move_back = move->reverse();
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_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
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_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) );
m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) );
m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
}
@ -144,15 +153,19 @@ std::string SpriteEaseExponential::title()
void SpriteEaseExponentialInOut::onEnter()
{
EaseSpriteDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease = CCEaseExponentialInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_back = move_ease->reverse(); //--> reverse()
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
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();
@ -175,8 +188,10 @@ std::string SpriteEaseExponentialInOut::title()
void SpriteEaseSine::onEnter()
{
EaseSpriteDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0));
CCActionInterval* move_back = move->reverse();
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_back = move_ease_out->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL);
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
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));
@ -211,15 +227,19 @@ std::string SpriteEaseSine::title()
void SpriteEaseSineInOut::onEnter()
{
EaseSpriteDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130,0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease = CCEaseSineInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_back = move_ease->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
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();
@ -241,7 +261,10 @@ std::string SpriteEaseSineInOut::title()
void SpriteEaseElastic::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_ease_in = CCEaseElasticIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
@ -249,10 +272,12 @@ void SpriteEaseElastic::onEnter()
CCActionInterval* move_ease_out = CCEaseElasticOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
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_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
@ -275,7 +300,9 @@ void SpriteEaseElasticInOut::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_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_inout_back3 = move_ease_inout3->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move_ease_inout1, move_ease_inout_back1, NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_inout2, move_ease_inout_back2, NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_inout3, move_ease_inout_back3, NULL);
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
CCFiniteTimeAction* seq1 = CCSequence::actions(move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), 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_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
@ -312,7 +340,10 @@ std::string SpriteEaseElasticInOut::title()
void SpriteEaseBounce::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_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_back = move_ease_out->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL);
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
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_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
@ -346,15 +379,19 @@ std::string SpriteEaseBounce::title()
void SpriteEaseBounceInOut::onEnter()
{
EaseSpriteDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease = CCEaseBounceInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_back = move_ease->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
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();
@ -377,22 +414,27 @@ std::string SpriteEaseBounceInOut::title()
void SpriteEaseBack::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_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_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();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL);
CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL);
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
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_tamara->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
m_kathia->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
}
@ -410,14 +452,19 @@ std::string SpriteEaseBack::title()
void SpriteEaseBackInOut::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_ease = CCEaseBackInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_back = move_ease->reverse();
CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);
CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f);
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();
@ -440,9 +487,11 @@ std::string SpriteEaseBackInOut::title()
void SpeedTest::onEnter()
{
EaseSpriteDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
// 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 *rot1 = CCRotateBy::actionWithDuration(4, 360*2);
CCActionInterval *rot2 = rot1->reverse();
@ -459,9 +508,9 @@ void SpeedTest::onEnter()
action2->setTag(kTagAction1);
action3->setTag(kTagAction1);
m_grossini->runAction( action2 );
m_tamara->runAction( action3 );
m_kathia->runAction( action );
m_grossini->runAction(action2);
m_tamara->runAction(action3);
m_kathia->runAction(action);
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
{
ccDrawInit();
ccGLInvalidateStateCache();
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
CCTextureCache::reloadAllTextures();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);