2014-01-14 06:48:12 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2012 cocos2d-x.org
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2014-01-14 06:48:12 +08:00
|
|
|
|
2022-02-24 18:45:25 +08:00
|
|
|
https://adxeproject.github.io/
|
2014-01-14 06:48:12 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-03-19 18:20:32 +08:00
|
|
|
#include "ActionsProgressTest.h"
|
|
|
|
#include "../testResource.h"
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
ActionsProgressTests::ActionsProgressTests()
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2015-04-03 14:31:03 +08:00
|
|
|
ADD_TEST_CASE(SpriteProgressToRadial);
|
|
|
|
ADD_TEST_CASE(SpriteProgressToHorizontal);
|
|
|
|
ADD_TEST_CASE(SpriteProgressToVertical);
|
|
|
|
ADD_TEST_CASE(SpriteProgressToRadialMidpointChanged);
|
|
|
|
ADD_TEST_CASE(SpriteProgressBarVarious);
|
|
|
|
ADD_TEST_CASE(SpriteProgressBarTintAndFade);
|
|
|
|
ADD_TEST_CASE(SpriteProgressWithSpriteFrame);
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteDemo
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2021-12-28 16:06:23 +08:00
|
|
|
SpriteDemo::SpriteDemo() {}
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
SpriteDemo::~SpriteDemo() {}
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string SpriteDemo::title() const
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ActionsProgressTest";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SpriteDemo::onEnter()
|
|
|
|
{
|
2015-04-03 14:31:03 +08:00
|
|
|
TestCase::onEnter();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto background = LayerColor::create(Color4B(255, 0, 0, 255));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(background, -10);
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressToRadial
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressToRadial::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 00:13:14 +08:00
|
|
|
auto to1 = Sequence::createWithTwoActions(ProgressTo::create(2, 100), ProgressTo::create(0, 0));
|
|
|
|
auto to2 = Sequence::createWithTwoActions(ProgressTo::create(2, 100), ProgressTo::create(0, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
2021-12-28 16:06:23 +08:00
|
|
|
left->setType(ProgressTimer::Type::RADIAL);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2021-12-28 16:06:23 +08:00
|
|
|
left->setPosition(100, s.height / 2);
|
|
|
|
left->runAction(RepeatForever::create(to1));
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto right = ProgressTimer::create(Sprite::create(s_pathBlock));
|
2013-07-26 17:28:18 +08:00
|
|
|
right->setType(ProgressTimer::Type::RADIAL);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Makes the ridial CCW
|
2016-09-05 10:02:05 +08:00
|
|
|
right->setReverseDirection(true);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2021-12-28 16:06:23 +08:00
|
|
|
right->setPosition(s.width - 100, s.height / 2);
|
|
|
|
right->runAction(RepeatForever::create(to2));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string SpriteProgressToRadial::subtitle() const
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ProgressTo Radial";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressToHorizontal
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SpriteProgressToHorizontal::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-05-15 00:13:14 +08:00
|
|
|
auto to1 = Sequence::createWithTwoActions(ProgressTo::create(2, 100), ProgressTo::create(0, 0));
|
|
|
|
auto to2 = Sequence::createWithTwoActions(ProgressTo::create(2, 100), ProgressTo::create(0, 0));
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
2013-07-26 17:28:18 +08:00
|
|
|
left->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the left since the midpoint is 0 for the x
|
2021-12-28 16:06:23 +08:00
|
|
|
left->setMidpoint(Vec2(0.0f, 0.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
|
2019-09-24 11:31:35 +08:00
|
|
|
left->setBarChangeRate(Vec2(1.0f, 0.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2021-12-28 16:06:23 +08:00
|
|
|
left->setPosition(100, s.height / 2);
|
|
|
|
left->runAction(RepeatForever::create(to1));
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-26 17:28:18 +08:00
|
|
|
right->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the left since the midpoint is 1 for the x
|
2019-09-24 11:31:35 +08:00
|
|
|
right->setMidpoint(Vec2(1.0f, 0.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
|
2019-09-24 11:31:35 +08:00
|
|
|
right->setBarChangeRate(Vec2(1.0f, 0.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2021-12-28 16:06:23 +08:00
|
|
|
right->setPosition(s.width - 100, s.height / 2);
|
|
|
|
right->runAction(RepeatForever::create(to2));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string SpriteProgressToHorizontal::subtitle() const
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ProgressTo Horizontal";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressToVertical
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressToVertical::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-05-15 00:13:14 +08:00
|
|
|
auto to1 = Sequence::createWithTwoActions(ProgressTo::create(2, 100), ProgressTo::create(0, 0));
|
|
|
|
auto to2 = Sequence::createWithTwoActions(ProgressTo::create(2, 100), ProgressTo::create(0, 0));
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
2013-07-26 17:28:18 +08:00
|
|
|
left->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2021-12-28 16:06:23 +08:00
|
|
|
left->setMidpoint(Vec2(0.0f, 0.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2019-09-24 11:31:35 +08:00
|
|
|
left->setBarChangeRate(Vec2(0.0f, 1.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2021-12-28 16:06:23 +08:00
|
|
|
left->setPosition(100, s.height / 2);
|
|
|
|
left->runAction(RepeatForever::create(to1));
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-26 17:28:18 +08:00
|
|
|
right->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2014-05-15 01:07:09 +08:00
|
|
|
right->setMidpoint(Vec2(0, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2014-05-15 01:07:09 +08:00
|
|
|
right->setBarChangeRate(Vec2(0, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2021-12-28 16:06:23 +08:00
|
|
|
right->setPosition(s.width - 100, s.height / 2);
|
|
|
|
right->runAction(RepeatForever::create(to2));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string SpriteProgressToVertical::subtitle() const
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ProgressTo Vertical";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressToRadialMidpointChanged
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressToRadialMidpointChanged::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2014-05-15 00:13:14 +08:00
|
|
|
auto action = Sequence::createWithTwoActions(ProgressTo::create(2, 100), ProgressTo::create(0, 0));
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2021-12-28 16:06:23 +08:00
|
|
|
* Our image on the left should be a radial progress indicator, clockwise
|
|
|
|
*/
|
2013-08-16 16:05:27 +08:00
|
|
|
auto left = ProgressTimer::create(Sprite::create(s_pathBlock));
|
2013-07-26 17:28:18 +08:00
|
|
|
left->setType(ProgressTimer::Type::RADIAL);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2014-05-15 01:07:09 +08:00
|
|
|
left->setMidpoint(Vec2(0.25f, 0.75f));
|
2021-12-28 16:06:23 +08:00
|
|
|
left->setPosition(100, s.height / 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
left->runAction(RepeatForever::create(action->clone()));
|
2012-03-19 18:20:32 +08:00
|
|
|
|
|
|
|
/**
|
2021-12-28 16:06:23 +08:00
|
|
|
* Our image on the left should be a radial progress indicator, counter clockwise
|
|
|
|
*/
|
2013-08-16 16:05:27 +08:00
|
|
|
auto right = ProgressTimer::create(Sprite::create(s_pathBlock));
|
2013-07-26 17:28:18 +08:00
|
|
|
right->setType(ProgressTimer::Type::RADIAL);
|
2014-05-15 01:07:09 +08:00
|
|
|
right->setMidpoint(Vec2(0.75f, 0.25f));
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2021-12-28 16:06:23 +08:00
|
|
|
* Note the reverse property (default=NO) is only added to the right image. That's how
|
|
|
|
* we get a counter clockwise progress.
|
|
|
|
*/
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2021-12-28 16:06:23 +08:00
|
|
|
right->setPosition(s.width - 100, s.height / 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction(RepeatForever::create(action->clone()));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string SpriteProgressToRadialMidpointChanged::subtitle() const
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Radial w/ Different Midpoints";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressBarVarious
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressBarVarious::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 00:13:14 +08:00
|
|
|
auto to = Sequence::createWithTwoActions(ProgressTo::create(2, 100), ProgressTo::create(0, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
2013-07-26 17:28:18 +08:00
|
|
|
left->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2014-05-15 01:07:09 +08:00
|
|
|
left->setMidpoint(Vec2(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2019-09-24 11:31:35 +08:00
|
|
|
left->setBarChangeRate(Vec2(1.0f, 0.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2021-12-28 16:06:23 +08:00
|
|
|
left->setPosition(100, s.height / 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
left->runAction(RepeatForever::create(to->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto middle = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-26 17:28:18 +08:00
|
|
|
middle->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2014-05-15 01:07:09 +08:00
|
|
|
middle->setMidpoint(Vec2(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2021-12-28 16:06:23 +08:00
|
|
|
middle->setBarChangeRate(Vec2(1, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(middle);
|
2021-12-28 16:06:23 +08:00
|
|
|
middle->setPosition(s.width / 2, s.height / 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
middle->runAction(RepeatForever::create(to->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-26 17:28:18 +08:00
|
|
|
right->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2014-05-15 01:07:09 +08:00
|
|
|
right->setMidpoint(Vec2(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2014-05-15 01:07:09 +08:00
|
|
|
right->setBarChangeRate(Vec2(0, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2021-12-28 16:06:23 +08:00
|
|
|
right->setPosition(s.width - 100, s.height / 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction(RepeatForever::create(to->clone()));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string SpriteProgressBarVarious::subtitle() const
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ProgressTo Bar Mid";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressBarTintAndFade
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressBarTintAndFade::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto to = Sequence::createWithTwoActions(ProgressTo::create(6, 100), ProgressTo::create(0, 0));
|
|
|
|
auto tint = Sequence::create(TintTo::create(1, 255, 0, 0), TintTo::create(1, 0, 255, 0),
|
|
|
|
TintTo::create(1, 0, 0, 255), nullptr);
|
|
|
|
auto fade = Sequence::create(FadeTo::create(1.0f, 0), FadeTo::create(1.0f, 255), nullptr);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
2013-07-26 17:28:18 +08:00
|
|
|
left->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2014-05-15 01:07:09 +08:00
|
|
|
left->setMidpoint(Vec2(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2019-09-24 11:31:35 +08:00
|
|
|
left->setBarChangeRate(Vec2(1.0f, 0.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2021-12-28 16:06:23 +08:00
|
|
|
left->setPosition(100, s.height / 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
left->runAction(RepeatForever::create(to->clone()));
|
|
|
|
left->runAction(RepeatForever::create(tint->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
left->addChild(Label::createWithTTF("Tint", "fonts/Marker Felt.ttf", 20.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto middle = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-26 17:28:18 +08:00
|
|
|
middle->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2014-05-15 01:07:09 +08:00
|
|
|
middle->setMidpoint(Vec2(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2014-05-15 01:07:09 +08:00
|
|
|
middle->setBarChangeRate(Vec2(1, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(middle);
|
2021-12-28 16:06:23 +08:00
|
|
|
middle->setPosition(s.width / 2, s.height / 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
middle->runAction(RepeatForever::create(to->clone()));
|
|
|
|
middle->runAction(RepeatForever::create(fade->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
middle->addChild(Label::createWithTTF("Fade", "fonts/Marker Felt.ttf", 20.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-26 17:28:18 +08:00
|
|
|
right->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2014-05-15 01:07:09 +08:00
|
|
|
right->setMidpoint(Vec2(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2014-05-15 01:07:09 +08:00
|
|
|
right->setBarChangeRate(Vec2(0, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2021-12-28 16:06:23 +08:00
|
|
|
right->setPosition(s.width - 100, s.height / 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction(RepeatForever::create(to->clone()));
|
2021-12-28 16:06:23 +08:00
|
|
|
right->runAction(RepeatForever::create(tint->clone()));
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction(RepeatForever::create(fade->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
right->addChild(Label::createWithTTF("Tint and Fade", "fonts/Marker Felt.ttf", 20.0f));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string SpriteProgressBarTintAndFade::subtitle() const
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ProgressTo Bar Mid";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressWithSpriteFrame
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressWithSpriteFrame::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 00:13:14 +08:00
|
|
|
auto to = Sequence::createWithTwoActions(ProgressTo::create(6, 100), ProgressTo::create(0, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto left = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_01.png"));
|
2013-07-26 17:28:18 +08:00
|
|
|
left->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2014-05-15 01:07:09 +08:00
|
|
|
left->setMidpoint(Vec2(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2019-09-24 11:31:35 +08:00
|
|
|
left->setBarChangeRate(Vec2(1.0f, 0.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2021-12-28 16:06:23 +08:00
|
|
|
left->setPosition(100, s.height / 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
left->runAction(RepeatForever::create(to->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto middle = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_02.png"));
|
2013-07-26 17:28:18 +08:00
|
|
|
middle->setType(ProgressTimer::Type::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2014-05-15 01:07:09 +08:00
|
|
|
middle->setMidpoint(Vec2(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2014-05-15 01:07:09 +08:00
|
|
|
middle->setBarChangeRate(Vec2(1, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(middle);
|
2021-12-28 16:06:23 +08:00
|
|
|
middle->setPosition(s.width / 2, s.height / 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
middle->runAction(RepeatForever::create(to->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto right = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_03.png"));
|
2013-07-26 17:28:18 +08:00
|
|
|
right->setType(ProgressTimer::Type::RADIAL);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2014-05-15 01:07:09 +08:00
|
|
|
right->setMidpoint(Vec2(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2014-05-15 01:07:09 +08:00
|
|
|
right->setBarChangeRate(Vec2(0, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2021-12-28 16:06:23 +08:00
|
|
|
right->setPosition(s.width - 100, s.height / 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction(RepeatForever::create(to->clone()));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string SpriteProgressWithSpriteFrame::subtitle() const
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Progress With Sprite Frame";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|