2012-03-26 16:46:23 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2009 Lam Pham
|
2012-09-24 21:22:20 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2012 Ricardo Quesada
|
2016-08-05 09:42:15 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
2012-03-26 16:46:23 +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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
2014-05-01 10:09:13 +08:00
|
|
|
#include "2d/CCTransitionProgress.h"
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "base/CCDirector.h"
|
2014-05-01 10:09:13 +08:00
|
|
|
#include "2d/CCRenderTexture.h"
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "2d/CCProgressTimer.h"
|
|
|
|
#include "2d/CCActionInstant.h"
|
|
|
|
#include "2d/CCActionProgressTimer.h"
|
2012-03-26 16:46:23 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
enum {
|
2013-06-20 14:13:12 +08:00
|
|
|
kSceneRadial = 0xc001,
|
2012-03-26 16:46:23 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
TransitionProgress::TransitionProgress()
|
2013-06-15 14:03:30 +08:00
|
|
|
: _to(0.0f)
|
|
|
|
, _from(0.0f)
|
2013-12-18 17:47:20 +08:00
|
|
|
, _sceneToBeModified(nullptr)
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
TransitionProgress* TransitionProgress::create(float t, Scene* scene)
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
TransitionProgress* newScene = new (std::nothrow) TransitionProgress();
|
2013-12-18 17:47:20 +08:00
|
|
|
if(newScene && newScene->initWithDuration(t, scene))
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2013-12-18 17:47:20 +08:00
|
|
|
newScene->autorelease();
|
|
|
|
return newScene;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
2013-12-18 17:47:20 +08:00
|
|
|
CC_SAFE_DELETE(newScene);
|
|
|
|
return nullptr;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
// TransitionProgress
|
|
|
|
void TransitionProgress::onEnter()
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
TransitionScene::onEnter();
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
setupTransition();
|
|
|
|
|
|
|
|
// create a transparent color layer
|
|
|
|
// in which we are going to add our rendertextures
|
2013-07-12 06:24:23 +08:00
|
|
|
Size size = Director::getInstance()->getWinSize();
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// create the second render texture for outScene
|
2014-09-02 11:21:11 +08:00
|
|
|
RenderTexture *texture = RenderTexture::create((int)size.width, (int)size.height,Texture2D::PixelFormat::RGBA8888,GL_DEPTH24_STENCIL8);
|
2014-05-15 01:07:09 +08:00
|
|
|
texture->getSprite()->setAnchorPoint(Vec2(0.5f,0.5f));
|
2014-08-28 11:41:18 +08:00
|
|
|
texture->setPosition(size.width/2, size.height/2);
|
2014-05-15 01:07:09 +08:00
|
|
|
texture->setAnchorPoint(Vec2(0.5f,0.5f));
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// render outScene to its texturebuffer
|
2013-12-05 03:54:57 +08:00
|
|
|
texture->beginWithClear(0, 0, 0, 1);
|
2013-06-15 14:03:30 +08:00
|
|
|
_sceneToBeModified->visit();
|
2012-04-19 14:35:52 +08:00
|
|
|
texture->end();
|
2012-03-26 16:46:23 +08:00
|
|
|
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// Since we've passed the outScene to the texture we don't need it.
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_sceneToBeModified == _outScene)
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
hideOutShowIn();
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
// We need the texture in RenderTexture.
|
2013-12-18 17:47:20 +08:00
|
|
|
ProgressTimer *node = progressTimerNodeWithRenderTexture(texture);
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// create the blend action
|
2016-08-22 09:39:58 +08:00
|
|
|
auto layerAction = Sequence::create(
|
2013-06-20 14:13:12 +08:00
|
|
|
ProgressFromTo::create(_duration, _from, _to),
|
2013-07-16 03:43:22 +08:00
|
|
|
CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
|
2013-12-18 17:47:20 +08:00
|
|
|
nullptr);
|
2012-04-19 14:35:52 +08:00
|
|
|
// run the blend action
|
2013-12-18 17:47:20 +08:00
|
|
|
node->runAction(layerAction);
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// add the layer (which contains our two rendertextures) to the scene
|
2013-12-18 17:47:20 +08:00
|
|
|
addChild(node, 2, kSceneRadial);
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// clean up on exit
|
2013-06-20 14:13:12 +08:00
|
|
|
void TransitionProgress::onExit()
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// remove our layer and release all containing objects
|
2013-06-20 14:13:12 +08:00
|
|
|
removeChildByTag(kSceneRadial, true);
|
|
|
|
TransitionScene::onExit();
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void TransitionProgress::sceneOrder()
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_isInSceneOnTop = false;
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void TransitionProgress::setupTransition()
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_sceneToBeModified = _outScene;
|
|
|
|
_from = 100;
|
|
|
|
_to = 0;
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ProgressTimer* TransitionProgress::progressTimerNodeWithRenderTexture(RenderTexture* texture)
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2013-07-20 13:01:27 +08:00
|
|
|
CCASSERT(false, "override me - abstract class");
|
2013-12-18 17:47:20 +08:00
|
|
|
return nullptr;
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
// TransitionProgressRadialCCW
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ProgressTimer* TransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(RenderTexture* texture)
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Size size = Director::getInstance()->getWinSize();
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
ProgressTimer* node = ProgressTimer::create(texture->getSprite());
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// but it is flipped upside down so we flip the sprite
|
2013-12-18 17:47:20 +08:00
|
|
|
node->getSprite()->setFlippedY(true);
|
|
|
|
node->setType(ProgressTimer::Type::RADIAL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Return the radial type that we want to use
|
2013-12-18 17:47:20 +08:00
|
|
|
node->setReverseDirection(false);
|
|
|
|
node->setPercentage(100);
|
2014-08-28 11:41:18 +08:00
|
|
|
node->setPosition(size.width/2, size.height/2);
|
2014-05-15 01:07:09 +08:00
|
|
|
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
return node;
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
TransitionProgressRadialCCW* TransitionProgressRadialCCW::create(float t, Scene* scene)
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
TransitionProgressRadialCCW* newScene = new (std::nothrow) TransitionProgressRadialCCW();
|
2013-12-18 17:47:20 +08:00
|
|
|
if(newScene && newScene->initWithDuration(t, scene))
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2013-12-18 17:47:20 +08:00
|
|
|
newScene->autorelease();
|
|
|
|
return newScene;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
2013-12-18 17:47:20 +08:00
|
|
|
CC_SAFE_DELETE(newScene);
|
|
|
|
return nullptr;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
// TransitionProgressRadialCW
|
|
|
|
TransitionProgressRadialCW* TransitionProgressRadialCW::create(float t, Scene* scene)
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
TransitionProgressRadialCW* newScene = new (std::nothrow) TransitionProgressRadialCW();
|
2013-12-18 17:47:20 +08:00
|
|
|
if(newScene && newScene->initWithDuration(t, scene))
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2013-12-18 17:47:20 +08:00
|
|
|
newScene->autorelease();
|
|
|
|
return newScene;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
2013-12-18 17:47:20 +08:00
|
|
|
CC_SAFE_DELETE(newScene);
|
|
|
|
return nullptr;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(RenderTexture* texture)
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Size size = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
ProgressTimer* node = ProgressTimer::create(texture->getSprite());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// but it is flipped upside down so we flip the sprite
|
2013-12-18 17:47:20 +08:00
|
|
|
node->getSprite()->setFlippedY(true);
|
|
|
|
node->setType( ProgressTimer::Type::RADIAL );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Return the radial type that we want to use
|
2013-12-18 17:47:20 +08:00
|
|
|
node->setReverseDirection(true);
|
|
|
|
node->setPercentage(100);
|
2014-08-28 11:41:18 +08:00
|
|
|
node->setPosition(size.width/2, size.height/2);
|
2014-05-15 01:07:09 +08:00
|
|
|
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
return node;
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
// TransitionProgressHorizontal
|
|
|
|
TransitionProgressHorizontal* TransitionProgressHorizontal::create(float t, Scene* scene)
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
TransitionProgressHorizontal* newScene = new (std::nothrow) TransitionProgressHorizontal();
|
2013-12-18 17:47:20 +08:00
|
|
|
if(newScene && newScene->initWithDuration(t, scene))
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2013-12-18 17:47:20 +08:00
|
|
|
newScene->autorelease();
|
|
|
|
return newScene;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
2013-12-18 17:47:20 +08:00
|
|
|
CC_SAFE_DELETE(newScene);
|
|
|
|
return nullptr;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture(RenderTexture* texture)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Size size = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
ProgressTimer* node = ProgressTimer::create(texture->getSprite());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// but it is flipped upside down so we flip the sprite
|
2013-12-18 17:47:20 +08:00
|
|
|
node->getSprite()->setFlippedY(true);
|
|
|
|
node->setType( ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
node->setMidpoint(Vec2(1, 0));
|
|
|
|
node->setBarChangeRate(Vec2(1,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
node->setPercentage(100);
|
2014-08-28 11:41:18 +08:00
|
|
|
node->setPosition(size.width/2, size.height/2);
|
2014-05-15 01:07:09 +08:00
|
|
|
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
return node;
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
// TransitionProgressVertical
|
|
|
|
TransitionProgressVertical* TransitionProgressVertical::create(float t, Scene* scene)
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
TransitionProgressVertical* newScene = new (std::nothrow) TransitionProgressVertical();
|
2013-12-18 17:47:20 +08:00
|
|
|
if(newScene && newScene->initWithDuration(t, scene))
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2013-12-18 17:47:20 +08:00
|
|
|
newScene->autorelease();
|
|
|
|
return newScene;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
2013-12-18 17:47:20 +08:00
|
|
|
CC_SAFE_DELETE(newScene);
|
|
|
|
return nullptr;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ProgressTimer* TransitionProgressVertical::progressTimerNodeWithRenderTexture(RenderTexture* texture)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Size size = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
ProgressTimer* node = ProgressTimer::create(texture->getSprite());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// but it is flipped upside down so we flip the sprite
|
2013-12-18 17:47:20 +08:00
|
|
|
node->getSprite()->setFlippedY(true);
|
|
|
|
node->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
node->setMidpoint(Vec2(0, 0));
|
|
|
|
node->setBarChangeRate(Vec2(0,1));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
node->setPercentage(100);
|
2014-08-28 11:41:18 +08:00
|
|
|
node->setPosition(size.width/2, size.height/2);
|
2014-05-15 01:07:09 +08:00
|
|
|
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
return node;
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
// TransitionProgressInOut
|
|
|
|
TransitionProgressInOut* TransitionProgressInOut::create(float t, Scene* scene)
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
TransitionProgressInOut* newScene = new (std::nothrow) TransitionProgressInOut();
|
2013-12-18 17:47:20 +08:00
|
|
|
if(newScene && newScene->initWithDuration(t, scene))
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2013-12-18 17:47:20 +08:00
|
|
|
newScene->autorelease();
|
|
|
|
return newScene;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
2013-12-18 17:47:20 +08:00
|
|
|
CC_SAFE_DELETE(newScene);
|
|
|
|
return nullptr;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void TransitionProgressInOut::sceneOrder()
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_isInSceneOnTop = false;
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void TransitionProgressInOut::setupTransition()
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_sceneToBeModified = _inScene;
|
|
|
|
_from = 0;
|
|
|
|
_to = 100;
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ProgressTimer* TransitionProgressInOut::progressTimerNodeWithRenderTexture(RenderTexture* texture)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Size size = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
ProgressTimer* node = ProgressTimer::create(texture->getSprite());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// but it is flipped upside down so we flip the sprite
|
2013-12-18 17:47:20 +08:00
|
|
|
node->getSprite()->setFlippedY(true);
|
|
|
|
node->setType( ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
node->setMidpoint(Vec2(0.5f, 0.5f));
|
|
|
|
node->setBarChangeRate(Vec2(1, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
node->setPercentage(0);
|
2014-08-28 11:41:18 +08:00
|
|
|
node->setPosition(size.width/2, size.height/2);
|
2014-05-15 01:07:09 +08:00
|
|
|
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
return node;
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
// TransitionProgressOutIn
|
|
|
|
TransitionProgressOutIn* TransitionProgressOutIn::create(float t, Scene* scene)
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
TransitionProgressOutIn* newScene = new (std::nothrow) TransitionProgressOutIn();
|
2013-12-18 17:47:20 +08:00
|
|
|
if(newScene && newScene->initWithDuration(t, scene))
|
2012-11-01 22:12:13 +08:00
|
|
|
{
|
2013-12-18 17:47:20 +08:00
|
|
|
newScene->autorelease();
|
|
|
|
return newScene;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
2013-12-18 17:47:20 +08:00
|
|
|
CC_SAFE_DELETE(newScene);
|
|
|
|
return nullptr;
|
2012-11-01 22:12:13 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(RenderTexture* texture)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Size size = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
ProgressTimer* node = ProgressTimer::create(texture->getSprite());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// but it is flipped upside down so we flip the sprite
|
2013-12-18 17:47:20 +08:00
|
|
|
node->getSprite()->setFlippedY(true);
|
|
|
|
node->setType( ProgressTimer::Type::BAR );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
node->setMidpoint(Vec2(0.5f, 0.5f));
|
|
|
|
node->setBarChangeRate(Vec2(1, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
node->setPercentage(100);
|
2014-08-28 11:41:18 +08:00
|
|
|
node->setPosition(size.width/2, size.height/2);
|
2014-05-15 01:07:09 +08:00
|
|
|
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 17:47:20 +08:00
|
|
|
return node;
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_END
|