2010-07-09 16:26:01 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "CCRadialTransition.h"
|
2010-08-18 11:06:48 +08:00
|
|
|
#include "CCDirector.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"
|
|
|
|
//#import "Support/CGPointExtension.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kSceneRadial = 0xc001,
|
|
|
|
};
|
|
|
|
|
|
|
|
CCRadialCCWTransition::CCRadialCCWTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCRadialCCWTransition::~CCRadialCCWTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCRadialCCWTransition::sceneOrder()
|
|
|
|
{
|
|
|
|
m_bIsInSceneOnTop = false;
|
|
|
|
}
|
|
|
|
|
2010-07-28 15:27:51 +08:00
|
|
|
CCProgressTimerType CCRadialCCWTransition::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
|
|
|
|
|
|
|
void CCRadialCCWTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
2010-07-13 09:48:39 +08:00
|
|
|
// create a transparent color layer
|
|
|
|
// in which we are going to add our rendertextures
|
2010-08-18 11:06:48 +08:00
|
|
|
CGSize size = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
/** @todo CCProgressTimer, CCRenderTexture
|
2010-07-13 09:48:39 +08:00
|
|
|
|
|
|
|
// create the second render texture for outScene
|
2010-08-18 11:06:48 +08:00
|
|
|
CCRenderTexture *outTexture = CCRenderTexture::renderTextureWithWidth:size.width height:size.height];
|
2010-07-13 09:48:39 +08:00
|
|
|
outTexture.sprite.anchorPoint= ccp(0.5f,0.5f);
|
|
|
|
outTexture.position = ccp(size.width/2, size.height/2);
|
|
|
|
outTexture.anchorPoint = ccp(0.5f,0.5f);
|
|
|
|
|
|
|
|
// render outScene to its texturebuffer
|
|
|
|
[outTexture clear:0 g:0 b:0 a:1];
|
|
|
|
[outTexture begin];
|
|
|
|
[outScene visit];
|
|
|
|
[outTexture end];
|
|
|
|
|
|
|
|
// Since we've passed the outScene to the texture we don't need it.
|
|
|
|
[self hideOutShowIn];
|
|
|
|
|
|
|
|
// We need the texture in RenderTexture.
|
|
|
|
CCProgressTimer *outNode = [CCProgressTimer progressWithTexture:outTexture.sprite.texture];
|
|
|
|
// but it's flipped upside down so we flip the sprite
|
|
|
|
outNode.sprite.flipY = YES;
|
|
|
|
// Return the radial type that we want to use
|
|
|
|
outNode.type = [self radialType];
|
|
|
|
outNode.percentage = 100.f;
|
|
|
|
outNode.position = ccp(size.width/2, size.height/2);
|
|
|
|
outNode.anchorPoint = ccp(0.5f,0.5f);
|
|
|
|
|
|
|
|
// create the blend action
|
|
|
|
CCIntervalAction * layerAction = [CCSequence actions:
|
|
|
|
[CCProgressFromTo actionWithDuration:duration from:100.f to:0.f],
|
|
|
|
[CCCallFunc actionWithTarget:self selector:@selector(finish)],
|
|
|
|
nil ];
|
|
|
|
// run the blend action
|
|
|
|
[outNode runAction: layerAction];
|
|
|
|
|
|
|
|
// add the layer (which contains our two rendertextures) to the scene
|
|
|
|
[self addChild: outNode z:2 tag:kSceneRadial];*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// clean up on exit
|
|
|
|
void CCRadialCCWTransition::onExit()
|
|
|
|
{
|
|
|
|
// remove our layer and release all containing objects
|
2010-07-14 16:30:25 +08:00
|
|
|
this->removeChildByTag(kSceneRadial, false);
|
|
|
|
__super::onExit();
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
|
2010-08-20 14:35:37 +08:00
|
|
|
CCRadialCCWTransition* CCRadialCCWTransition::transitionWithDuration(ccTime t, CCScene* scene)
|
|
|
|
{
|
|
|
|
CCRadialCCWTransition* pScene = new CCRadialCCWTransition();
|
|
|
|
pScene->initWithDuration(t, scene);
|
|
|
|
pScene->autorelease();
|
|
|
|
|
|
|
|
return pScene;
|
|
|
|
}
|
|
|
|
|
2010-07-28 15:27:51 +08:00
|
|
|
CCProgressTimerType CCRadialCWTransition::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-08-20 14:35:37 +08:00
|
|
|
CCRadialCWTransition* CCRadialCWTransition::transitionWithDuration(ccTime t, CCScene* scene)
|
|
|
|
{
|
|
|
|
CCRadialCWTransition* pScene = new CCRadialCWTransition();
|
|
|
|
pScene->initWithDuration(t, scene);
|
|
|
|
pScene->autorelease();
|
|
|
|
|
|
|
|
return pScene;
|
|
|
|
}
|
|
|
|
|
2010-08-04 15:46:12 +08:00
|
|
|
}//namespace cocos2d
|
2010-07-13 09:48:39 +08:00
|
|
|
|