2010-07-09 16:26:01 +08:00
|
|
|
/****************************************************************************
|
2011-03-19 14:45:51 +08:00
|
|
|
Copyright (c) 2010-2011 cocos2d-x.org
|
|
|
|
Copyright (c) 2009 Lam Pham
|
2010-07-09 16:26:01 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
#include "CCTransitionRadial.h"
|
2010-08-18 11:06:48 +08:00
|
|
|
#include "CCDirector.h"
|
2010-09-01 12:02:36 +08:00
|
|
|
#include "CCRenderTexture.h"
|
2010-12-22 15:15:04 +08:00
|
|
|
#include "CCActionInstant.h"
|
|
|
|
#include "CCActionProgressTimer.h"
|
2011-03-07 17:11:57 +08:00
|
|
|
#include "CCPointExtension.h"
|
2010-07-13 09:48:39 +08:00
|
|
|
|
2010-08-04 15:46:12 +08:00
|
|
|
namespace cocos2d {
|
2010-07-13 09:48:39 +08:00
|
|
|
|
|
|
|
//#import "CCDirector.h"
|
|
|
|
//#import "CCRadialTransition.h"
|
|
|
|
//#import "CCRenderTexture.h"
|
|
|
|
//#import "CCLayer.h"
|
|
|
|
//#import "CCInstantAction.h"
|
2011-03-07 17:11:57 +08:00
|
|
|
//#import "Support/CCPointExtension.h"
|
2010-07-13 09:48:39 +08:00
|
|
|
|
|
|
|
enum {
|
|
|
|
kSceneRadial = 0xc001,
|
|
|
|
};
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionRadialCCW::sceneOrder()
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
m_bIsInSceneOnTop = false;
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCProgressTimerType CCTransitionRadialCCW::radialType()
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
return kCCProgressTimerTypeRadialCCW;
|
2010-07-28 15:27:51 +08:00
|
|
|
}
|
2010-07-13 09:48:39 +08:00
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionRadialCCW::onEnter()
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
2010-09-02 14:54:42 +08:00
|
|
|
CCTransitionScene::onEnter();
|
2010-07-13 09:48:39 +08:00
|
|
|
// create a transparent color layer
|
|
|
|
// in which we are going to add our rendertextures
|
2011-03-07 17:11:57 +08:00
|
|
|
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
2010-07-13 09:48:39 +08:00
|
|
|
|
|
|
|
// create the second render texture for outScene
|
2010-09-01 12:02:36 +08:00
|
|
|
CCRenderTexture *outTexture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height);
|
2011-06-03 15:22:50 +08:00
|
|
|
|
|
|
|
if (NULL == outTexture)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-01 12:02:36 +08:00
|
|
|
outTexture->getSprite()->setAnchorPoint(ccp(0.5f,0.5f));
|
|
|
|
outTexture->setPosition(ccp(size.width/2, size.height/2));
|
|
|
|
outTexture->setAnchorPoint(ccp(0.5f,0.5f));
|
2010-07-13 09:48:39 +08:00
|
|
|
|
|
|
|
// render outScene to its texturebuffer
|
2010-09-01 12:02:36 +08:00
|
|
|
outTexture->clear(0,0,0,1);
|
|
|
|
outTexture->begin();
|
|
|
|
m_pOutScene->visit();
|
|
|
|
outTexture->end();
|
2010-07-13 09:48:39 +08:00
|
|
|
|
|
|
|
// Since we've passed the outScene to the texture we don't need it.
|
2010-09-01 12:02:36 +08:00
|
|
|
this->hideOutShowIn();
|
2010-07-13 09:48:39 +08:00
|
|
|
|
|
|
|
// We need the texture in RenderTexture.
|
2010-09-01 12:02:36 +08:00
|
|
|
CCProgressTimer *outNode = CCProgressTimer::progressWithTexture(outTexture->getSprite()->getTexture());
|
2010-07-13 09:48:39 +08:00
|
|
|
// but it's flipped upside down so we flip the sprite
|
2010-09-01 12:02:36 +08:00
|
|
|
outNode->getSprite()->setFlipY(true);
|
2010-07-13 09:48:39 +08:00
|
|
|
// Return the radial type that we want to use
|
2010-09-01 12:02:36 +08:00
|
|
|
outNode->setType(radialType());
|
|
|
|
outNode->setPercentage(100.f);
|
|
|
|
outNode->setPosition(ccp(size.width/2, size.height/2));
|
|
|
|
outNode->setAnchorPoint(ccp(0.5f,0.5f));
|
2010-07-13 09:48:39 +08:00
|
|
|
|
|
|
|
// create the blend action
|
2010-09-01 12:02:36 +08:00
|
|
|
CCAction * layerAction = CCSequence::actions
|
|
|
|
(
|
|
|
|
CCProgressFromTo::actionWithDuration(m_fDuration, 100.0f, 0.0f),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
);
|
2010-07-13 09:48:39 +08:00
|
|
|
// run the blend action
|
2010-09-01 12:02:36 +08:00
|
|
|
outNode->runAction(layerAction);
|
2010-07-13 09:48:39 +08:00
|
|
|
|
|
|
|
// add the layer (which contains our two rendertextures) to the scene
|
2010-09-01 12:02:36 +08:00
|
|
|
this->addChild(outNode, 2, kSceneRadial);
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// clean up on exit
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionRadialCCW::onExit()
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
// remove our layer and release all containing objects
|
2010-07-14 16:30:25 +08:00
|
|
|
this->removeChildByTag(kSceneRadial, false);
|
2010-09-02 14:54:42 +08:00
|
|
|
CCTransitionScene::onExit();
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionRadialCCW* CCTransitionRadialCCW::transitionWithDuration(ccTime t, CCScene* scene)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionRadialCCW* pScene = new CCTransitionRadialCCW();
|
2010-08-20 14:35:37 +08:00
|
|
|
pScene->initWithDuration(t, scene);
|
|
|
|
pScene->autorelease();
|
|
|
|
|
|
|
|
return pScene;
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCProgressTimerType CCTransitionRadialCW::radialType()
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
return kCCProgressTimerTypeRadialCW;
|
2010-07-28 15:27:51 +08:00
|
|
|
}
|
2010-07-13 09:48:39 +08:00
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionRadialCW* CCTransitionRadialCW::transitionWithDuration(ccTime t, CCScene* scene)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionRadialCW* pScene = new CCTransitionRadialCW();
|
2010-08-20 14:35:37 +08:00
|
|
|
pScene->initWithDuration(t, scene);
|
|
|
|
pScene->autorelease();
|
|
|
|
|
|
|
|
return pScene;
|
|
|
|
}
|
|
|
|
|
2010-08-04 15:46:12 +08:00
|
|
|
}//namespace cocos2d
|