2011-05-12 10:52:10 +08:00
|
|
|
#include "TransitionsTest.h"
|
|
|
|
#include "../testResource.h"
|
2011-06-08 10:02:07 +08:00
|
|
|
#include "CCConfiguration.h"
|
2011-05-12 10:52:10 +08:00
|
|
|
|
|
|
|
#define TRANSITION_DURATION (1.2f)
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class FadeWhiteTransition : public TransitionFade
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionFade::create(t, s, ccWHITE);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class FlipXLeftOver : public TransitionFlipX
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionFlipX::create(t, s, kTransitionOrientationLeftOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class FlipXRightOver : public TransitionFlipX
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionFlipX::create(t, s, kTransitionOrientationRightOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class FlipYUpOver : public TransitionFlipY
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionFlipY::create(t, s, kTransitionOrientationUpOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class FlipYDownOver : public TransitionFlipY
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionFlipY::create(t, s, kTransitionOrientationDownOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class FlipAngularLeftOver : public TransitionFlipAngular
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionFlipAngular::create(t, s, kTransitionOrientationLeftOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class FlipAngularRightOver : public TransitionFlipAngular
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionFlipAngular::create(t, s, kTransitionOrientationRightOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class ZoomFlipXLeftOver : public TransitionZoomFlipX
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionZoomFlipX::create(t, s, kTransitionOrientationLeftOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class ZoomFlipXRightOver : public TransitionZoomFlipX
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionZoomFlipX::create(t, s, kTransitionOrientationRightOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class ZoomFlipYUpOver : public TransitionZoomFlipY
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionZoomFlipY::create(t, s, kTransitionOrientationUpOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class ZoomFlipYDownOver : public TransitionZoomFlipY
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionZoomFlipY::create(t, s, kTransitionOrientationDownOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class ZoomFlipAngularLeftOver : public TransitionZoomFlipAngular
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionZoomFlipAngular::create(t, s, kTransitionOrientationLeftOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class ZoomFlipAngularRightOver : public TransitionZoomFlipAngular
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
return TransitionZoomFlipAngular::create(t, s, kTransitionOrientationRightOver);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class PageTransitionForward : public TransitionPageTurn
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->setDepthTest(true);
|
|
|
|
return TransitionPageTurn::create(t, s, false);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class PageTransitionBackward : public TransitionPageTurn
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:17:10 +08:00
|
|
|
static TransitionScene* create(float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->setDepthTest(true);
|
|
|
|
return TransitionPageTurn::create(t, s, true);
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
2011-05-12 10:52:10 +08:00
|
|
|
};
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
#define MAX_LAYER 41
|
2011-05-12 10:52:10 +08:00
|
|
|
|
2010-08-25 17:41:38 +08:00
|
|
|
static std::string transitions[MAX_LAYER] = {
|
2012-03-26 16:46:23 +08:00
|
|
|
"CCTransitionJumpZoom",
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
"CCTransitionProgressRadialCCW",
|
|
|
|
"CCTransitionProgressRadialCW",
|
|
|
|
"CCTransitionProgressHorizontal",
|
|
|
|
"CCTransitionProgressVertical",
|
|
|
|
"CCTransitionProgressInOut",
|
2012-03-26 16:46:23 +08:00
|
|
|
"CCTransitionProgressOutIn",
|
|
|
|
|
|
|
|
"CCTransitionCrossFade",
|
|
|
|
"TransitionPageForward",
|
|
|
|
"TransitionPageBackward",
|
|
|
|
"CCTransitionFadeTR",
|
|
|
|
"CCTransitionFadeBL",
|
|
|
|
"CCTransitionFadeUp",
|
|
|
|
"CCTransitionFadeDown",
|
|
|
|
"CCTransitionTurnOffTiles",
|
|
|
|
"CCTransitionSplitRows",
|
|
|
|
"CCTransitionSplitCols",
|
|
|
|
|
|
|
|
"CCTransitionFade",
|
2010-08-20 14:35:37 +08:00
|
|
|
"FadeWhiteTransition",
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2010-08-20 14:35:37 +08:00
|
|
|
"FlipXLeftOver",
|
|
|
|
"FlipXRightOver",
|
|
|
|
"FlipYUpOver",
|
|
|
|
"FlipYDownOver",
|
|
|
|
"FlipAngularLeftOver",
|
|
|
|
"FlipAngularRightOver",
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2010-08-20 14:35:37 +08:00
|
|
|
"ZoomFlipXLeftOver",
|
|
|
|
"ZoomFlipXRightOver",
|
|
|
|
"ZoomFlipYUpOver",
|
|
|
|
"ZoomFlipYDownOver",
|
|
|
|
"ZoomFlipAngularLeftOver",
|
|
|
|
"ZoomFlipAngularRightOver",
|
2011-05-12 10:52:10 +08:00
|
|
|
|
2012-03-26 16:46:23 +08:00
|
|
|
"CCTransitionShrinkGrow",
|
|
|
|
"CCTransitionRotoZoom",
|
|
|
|
|
|
|
|
"CCTransitionMoveInL",
|
|
|
|
"CCTransitionMoveInR",
|
|
|
|
"CCTransitionMoveInT",
|
|
|
|
"CCTransitionMoveInB",
|
|
|
|
"CCTransitionSlideInL",
|
|
|
|
"CCTransitionSlideInR",
|
|
|
|
"CCTransitionSlideInT",
|
|
|
|
"CCTransitionSlideInB",
|
|
|
|
|
|
|
|
|
2011-05-12 10:52:10 +08:00
|
|
|
};
|
|
|
|
static int s_nSceneIdx = 0;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TransitionScene* createTransition(int nIndex, float t, Scene* s)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2011-07-12 17:35:15 +08:00
|
|
|
// fix bug #486, without setDepthTest(false), FlipX,Y will flickers
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->setDepthTest(false);
|
2011-07-12 17:35:15 +08:00
|
|
|
|
2010-08-20 14:35:37 +08:00
|
|
|
switch(nIndex)
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
case 0: return TransitionJumpZoom::create(t, s);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
case 1: return TransitionProgressRadialCCW::create(t, s);
|
|
|
|
case 2: return TransitionProgressRadialCW::create(t, s);
|
|
|
|
case 3: return TransitionProgressHorizontal::create(t, s);
|
|
|
|
case 4: return TransitionProgressVertical::create(t, s);
|
|
|
|
case 5: return TransitionProgressInOut::create(t, s);
|
|
|
|
case 6: return TransitionProgressOutIn::create(t, s);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
case 7: return TransitionCrossFade::create(t,s);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
|
|
|
case 8: return PageTransitionForward::create(t, s);
|
|
|
|
case 9: return PageTransitionBackward::create(t, s);
|
2013-06-20 14:17:10 +08:00
|
|
|
case 10: return TransitionFadeTR::create(t, s);
|
|
|
|
case 11: return TransitionFadeBL::create(t, s);
|
|
|
|
case 12: return TransitionFadeUp::create(t, s);
|
|
|
|
case 13: return TransitionFadeDown::create(t, s);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
case 14: return TransitionTurnOffTiles::create(t, s);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
case 15: return TransitionSplitRows::create(t, s);
|
|
|
|
case 16: return TransitionSplitCols::create(t, s);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
case 17: return TransitionFade::create(t, s);
|
2012-06-14 15:13:16 +08:00
|
|
|
case 18: return FadeWhiteTransition::create(t, s);
|
|
|
|
|
|
|
|
case 19: return FlipXLeftOver::create(t, s);
|
|
|
|
case 20: return FlipXRightOver::create(t, s);
|
|
|
|
case 21: return FlipYUpOver::create(t, s);
|
|
|
|
case 22: return FlipYDownOver::create(t, s);
|
|
|
|
case 23: return FlipAngularLeftOver::create(t, s);
|
|
|
|
case 24: return FlipAngularRightOver::create(t, s);
|
|
|
|
|
|
|
|
case 25: return ZoomFlipXLeftOver::create(t, s);
|
|
|
|
case 26: return ZoomFlipXRightOver::create(t, s);
|
|
|
|
case 27: return ZoomFlipYUpOver::create(t, s);
|
|
|
|
case 28: return ZoomFlipYDownOver::create(t, s);
|
|
|
|
case 29: return ZoomFlipAngularLeftOver::create(t, s);
|
|
|
|
case 30: return ZoomFlipAngularRightOver::create(t, s);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
case 31: return TransitionShrinkGrow::create(t, s);
|
|
|
|
case 32: return TransitionRotoZoom::create(t, s);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
case 33: return TransitionMoveInL::create(t, s);
|
|
|
|
case 34: return TransitionMoveInR::create(t, s);
|
|
|
|
case 35: return TransitionMoveInT::create(t, s);
|
|
|
|
case 36: return TransitionMoveInB::create(t, s);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
case 37: return TransitionSlideInL::create(t, s);
|
|
|
|
case 38: return TransitionSlideInR::create(t, s);
|
|
|
|
case 39: return TransitionSlideInT::create(t, s);
|
|
|
|
case 40: return TransitionSlideInB::create(t, s);
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2010-08-20 17:08:30 +08:00
|
|
|
default: break;
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2011-05-12 10:52:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
void TransitionsTestScene::runThisTest()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer * pLayer = new TestLayer1();
|
2011-05-12 10:52:10 +08:00
|
|
|
addChild(pLayer);
|
|
|
|
pLayer->release();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(this);
|
2011-05-12 10:52:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TestLayer1::TestLayer1(void)
|
|
|
|
{
|
2010-08-20 14:35:37 +08:00
|
|
|
float x,y;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size = Director::sharedDirector()->getWinSize();
|
2010-08-20 14:35:37 +08:00
|
|
|
x = size.width;
|
|
|
|
y = size.height;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* bg1 = Sprite::create(s_back1);
|
2012-10-23 17:48:50 +08:00
|
|
|
bg1->setPosition( ccp(size.width/2, size.height/2) );
|
2010-08-20 14:35:37 +08:00
|
|
|
addChild(bg1, -1);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
LabelTTF* title = LabelTTF::create( (transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 );
|
2010-08-20 14:35:37 +08:00
|
|
|
addChild(title);
|
|
|
|
title->setColor( ccc3(255,32,32) );
|
2012-10-23 17:48:50 +08:00
|
|
|
title->setPosition( ccp(x/2, y-100) );
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
LabelTTF* label = LabelTTF::create("SCENE 1", "Marker Felt", 38);
|
2010-08-20 14:35:37 +08:00
|
|
|
label->setColor( ccc3(16,16,255));
|
2012-10-23 17:48:50 +08:00
|
|
|
label->setPosition( ccp(x/2,y/2));
|
2010-08-20 14:35:37 +08:00
|
|
|
addChild( label);
|
|
|
|
|
|
|
|
// menu
|
2013-06-20 14:17:10 +08:00
|
|
|
MenuItemImage *item1 = MenuItemImage::create(s_pPathB1, s_pPathB2, CC_CALLBACK_1(TestLayer1::backCallback, this) );
|
|
|
|
MenuItemImage *item2 = MenuItemImage::create(s_pPathR1, s_pPathR2, CC_CALLBACK_1(TestLayer1::restartCallback, this) );
|
|
|
|
MenuItemImage *item3 = MenuItemImage::create(s_pPathF1, s_pPathF2, CC_CALLBACK_1(TestLayer1::nextCallback, this) );
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Menu *menu = Menu::create(item1, item2, item3, NULL);
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
menu->setPosition( PointZero );
|
2012-10-23 17:48:50 +08:00
|
|
|
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
|
|
|
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
|
|
|
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(menu, 1);
|
2010-08-20 14:35:37 +08:00
|
|
|
|
|
|
|
schedule( schedule_selector(TestLayer1::step), 1.0f);
|
2011-05-12 10:52:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TestLayer1::~TestLayer1(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TestLayer1::restartCallback(Object* pSender)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new TransitionsTestScene();
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = new TestLayer2();
|
2010-08-20 14:35:37 +08:00
|
|
|
s->addChild(pLayer);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s);
|
2010-09-16 16:32:14 +08:00
|
|
|
s->release();
|
|
|
|
pLayer->release();
|
2011-05-12 10:52:10 +08:00
|
|
|
if (pScene)
|
2010-08-20 17:08:30 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(pScene);
|
2010-08-20 17:08:30 +08:00
|
|
|
}
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TestLayer1::nextCallback(Object* pSender)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2010-08-25 17:56:30 +08:00
|
|
|
s_nSceneIdx++;
|
|
|
|
s_nSceneIdx = s_nSceneIdx % MAX_LAYER;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new TransitionsTestScene();
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = new TestLayer2();
|
2010-08-20 14:35:37 +08:00
|
|
|
s->addChild(pLayer);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s);
|
2010-09-16 16:32:14 +08:00
|
|
|
s->release();
|
|
|
|
pLayer->release();
|
2011-05-12 10:52:10 +08:00
|
|
|
if (pScene)
|
2010-08-20 17:08:30 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(pScene);
|
2010-08-20 17:08:30 +08:00
|
|
|
}
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TestLayer1::backCallback(Object* pSender)
|
2011-05-12 10:52:10 +08:00
|
|
|
{
|
2010-08-25 17:56:30 +08:00
|
|
|
s_nSceneIdx--;
|
|
|
|
int total = MAX_LAYER;
|
|
|
|
if( s_nSceneIdx < 0 )
|
2012-04-19 14:35:52 +08:00
|
|
|
s_nSceneIdx += total;
|
2011-05-12 10:52:10 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new TransitionsTestScene();
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = new TestLayer2();
|
2010-08-20 14:35:37 +08:00
|
|
|
s->addChild(pLayer);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s);
|
2010-09-16 16:32:14 +08:00
|
|
|
s->release();
|
|
|
|
pLayer->release();
|
2011-05-12 10:52:10 +08:00
|
|
|
if (pScene)
|
2010-08-20 17:08:30 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(pScene);
|
2011-05-12 10:52:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TestLayer1::step(float dt)
|
2011-05-12 10:52:10 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void TestLayer1::onEnter()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onEnter();
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLog("Scene 1 onEnter");
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestLayer1::onEnterTransitionDidFinish()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onEnterTransitionDidFinish();
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLog("Scene 1: onEnterTransitionDidFinish");
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestLayer1::onExitTransitionDidStart()
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onExitTransitionDidStart();
|
2012-03-26 16:46:23 +08:00
|
|
|
CCLog("Scene 1: onExitTransitionDidStart");
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestLayer1::onExit()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onExit();
|
2012-03-26 16:46:23 +08:00
|
|
|
CCLog("Scene 1 onExit");
|
|
|
|
}
|
|
|
|
|
2011-05-12 10:52:10 +08:00
|
|
|
TestLayer2::TestLayer2()
|
|
|
|
{
|
2010-08-20 14:35:37 +08:00
|
|
|
float x,y;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size = Director::sharedDirector()->getWinSize();
|
2010-08-20 14:35:37 +08:00
|
|
|
x = size.width;
|
|
|
|
y = size.height;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* bg1 = Sprite::create(s_back2);
|
2012-10-23 17:48:50 +08:00
|
|
|
bg1->setPosition( ccp(size.width/2, size.height/2) );
|
2010-08-20 14:35:37 +08:00
|
|
|
addChild(bg1, -1);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
LabelTTF* title = LabelTTF::create((transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 );
|
2010-08-20 14:35:37 +08:00
|
|
|
addChild(title);
|
|
|
|
title->setColor( ccc3(255,32,32) );
|
2012-10-23 17:48:50 +08:00
|
|
|
title->setPosition( ccp(x/2, y-100) );
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
LabelTTF* label = LabelTTF::create("SCENE 2", "Marker Felt", 38);
|
2010-08-20 14:35:37 +08:00
|
|
|
label->setColor( ccc3(16,16,255));
|
2012-10-23 17:48:50 +08:00
|
|
|
label->setPosition( ccp(x/2,y/2));
|
2010-08-20 14:35:37 +08:00
|
|
|
addChild( label);
|
|
|
|
|
|
|
|
// menu
|
2013-06-20 14:17:10 +08:00
|
|
|
MenuItemImage *item1 = MenuItemImage::create(s_pPathB1, s_pPathB2, CC_CALLBACK_1(TestLayer2::backCallback, this) );
|
|
|
|
MenuItemImage *item2 = MenuItemImage::create(s_pPathR1, s_pPathR2, CC_CALLBACK_1(TestLayer2::restartCallback, this) );
|
|
|
|
MenuItemImage *item3 = MenuItemImage::create(s_pPathF1, s_pPathF2, CC_CALLBACK_1(TestLayer2::nextCallback, this) );
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Menu *menu = Menu::create(item1, item2, item3, NULL);
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
menu->setPosition( PointZero );
|
2012-10-23 17:48:50 +08:00
|
|
|
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
|
|
|
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
|
|
|
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(menu, 1);
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2011-05-12 10:52:10 +08:00
|
|
|
schedule(schedule_selector(TestLayer2::step), 1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
TestLayer2::~TestLayer2()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TestLayer2::restartCallback(Object* pSender)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new TransitionsTestScene();
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = new TestLayer1();
|
2010-08-20 14:35:37 +08:00
|
|
|
s->addChild(pLayer);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s);
|
2010-09-16 16:32:14 +08:00
|
|
|
s->release();
|
|
|
|
pLayer->release();
|
2011-05-12 10:52:10 +08:00
|
|
|
if (pScene)
|
2010-08-20 17:08:30 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(pScene);
|
2010-08-20 17:08:30 +08:00
|
|
|
}
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TestLayer2::nextCallback(Object* pSender)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2010-08-25 17:56:30 +08:00
|
|
|
s_nSceneIdx++;
|
|
|
|
s_nSceneIdx = s_nSceneIdx % MAX_LAYER;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new TransitionsTestScene();
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = new TestLayer1();
|
2010-08-20 14:35:37 +08:00
|
|
|
s->addChild(pLayer);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s);
|
2010-09-16 16:32:14 +08:00
|
|
|
s->release();
|
|
|
|
pLayer->release();
|
2011-05-12 10:52:10 +08:00
|
|
|
if (pScene)
|
2010-08-20 17:08:30 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(pScene);
|
2010-08-20 17:08:30 +08:00
|
|
|
}
|
2010-08-20 14:35:37 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TestLayer2::backCallback(Object* pSender)
|
2011-05-12 10:52:10 +08:00
|
|
|
{
|
2010-08-25 17:56:30 +08:00
|
|
|
s_nSceneIdx--;
|
|
|
|
int total = MAX_LAYER;
|
|
|
|
if( s_nSceneIdx < 0 )
|
2012-04-19 14:35:52 +08:00
|
|
|
s_nSceneIdx += total;
|
2011-05-12 10:52:10 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new TransitionsTestScene();
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = new TestLayer1();
|
2010-08-20 14:35:37 +08:00
|
|
|
s->addChild(pLayer);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s);
|
2010-09-16 16:32:14 +08:00
|
|
|
s->release();
|
|
|
|
pLayer->release();
|
2011-05-12 10:52:10 +08:00
|
|
|
if (pScene)
|
2010-08-20 17:08:30 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(pScene);
|
2011-05-12 10:52:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TestLayer2::step(float dt)
|
2011-05-12 10:52:10 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void TestLayer2::onEnter()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onEnter();
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLog("Scene 2 onEnter");
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestLayer2::onEnterTransitionDidFinish()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onEnterTransitionDidFinish();
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLog("Scene 2: onEnterTransitionDidFinish");
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestLayer2::onExitTransitionDidStart()
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onExitTransitionDidStart();
|
2012-03-26 16:46:23 +08:00
|
|
|
CCLog("Scene 2: onExitTransitionDidStart");
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestLayer2::onExit()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onExit();
|
2012-03-26 16:46:23 +08:00
|
|
|
CCLog("Scene 2 onExit");
|
|
|
|
}
|