2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
http://www.cocos2d-x.org
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +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:
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
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-04-08 14:16:29 +08:00
|
|
|
#include "RotateWorldTest.h"
|
|
|
|
#include "../testResource.h"
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
RotateWorldTests::RotateWorldTests()
|
|
|
|
{
|
|
|
|
ADD_TEST_CASE(RotateWorldTest);
|
|
|
|
}
|
|
|
|
|
2010-08-23 13:58:57 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TestLayer
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TestLayer::onEnter()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onEnter();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
float x, y;
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
x = size.width;
|
|
|
|
y = size.height;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
// auto array = [UIFont familyNames];
|
|
|
|
// for( String *s in array )
|
|
|
|
// NSLog( s );
|
2014-04-09 23:31:05 +08:00
|
|
|
auto label = Label::createWithSystemFont("cocos2d", "Tahoma", 64);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
label->setPosition(Vec2(x / 2, y / 2));
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(label);
|
2010-08-23 13:58:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteLayer
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteLayer::onEnter()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onEnter();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
float x, y;
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
x = size.width;
|
|
|
|
y = size.height;
|
|
|
|
|
|
|
|
auto sprite = Sprite::create(s_pathGrossini);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto spriteSister1 = Sprite::create(s_pathSister1);
|
|
|
|
auto spriteSister2 = Sprite::create(s_pathSister2);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setScale(1.5f);
|
|
|
|
spriteSister1->setScale(1.5f);
|
|
|
|
spriteSister2->setScale(1.5f);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
sprite->setPosition(Vec2(x / 2, y / 2));
|
|
|
|
spriteSister1->setPosition(Vec2(40.0f, y / 2));
|
|
|
|
spriteSister2->setPosition(Vec2(x - 40, y / 2));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto rot = RotateBy::create(16, -3600);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite);
|
|
|
|
addChild(spriteSister1);
|
|
|
|
addChild(spriteSister2);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->runAction(rot);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto jump1 = JumpBy::create(4, Vec2(-400, 0), 100, 4);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto jump2 = jump1->reverse();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
auto rot1 = RotateBy::create(4, 360 * 2);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto rot2 = rot1->reverse();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
spriteSister1->runAction(Repeat::create(Sequence::create(jump2, jump1, nullptr), 5));
|
|
|
|
spriteSister2->runAction(Repeat::create(Sequence::create(jump1->clone(), jump2->clone(), nullptr), 5));
|
|
|
|
|
|
|
|
spriteSister1->runAction(Repeat::create(Sequence::create(rot1, rot2, nullptr), 5));
|
|
|
|
spriteSister2->runAction(Repeat::create(Sequence::create(rot2->clone(), rot1->clone(), nullptr), 5));
|
2010-08-23 13:58:57 +08:00
|
|
|
}
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2010-08-23 13:58:57 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// RotateWorldMainLayer
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2010-08-23 13:58:57 +08:00
|
|
|
void RotateWorldMainLayer::onEnter()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onEnter();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
float x, y;
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
x = size.width;
|
|
|
|
y = size.height;
|
|
|
|
|
|
|
|
auto blue = LayerColor::create(Color4B(0, 0, 255, 255));
|
|
|
|
auto red = LayerColor::create(Color4B(255, 0, 0, 255));
|
|
|
|
auto green = LayerColor::create(Color4B(0, 255, 0, 255));
|
|
|
|
auto white = LayerColor::create(Color4B(255, 255, 255, 255));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
blue->setScale(0.5f);
|
2021-12-28 16:06:23 +08:00
|
|
|
blue->setPosition(Vec2(-x / 4, -y / 4));
|
|
|
|
blue->addChild(SpriteLayer::create());
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
red->setScale(0.5f);
|
2021-12-28 16:06:23 +08:00
|
|
|
red->setPosition(Vec2(x / 4, -y / 4));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
green->setScale(0.5f);
|
2021-12-28 16:06:23 +08:00
|
|
|
green->setPosition(Vec2(-x / 4, y / 4));
|
2012-06-14 15:13:16 +08:00
|
|
|
green->addChild(TestLayer::create());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
white->setScale(0.5f);
|
2021-12-28 16:06:23 +08:00
|
|
|
white->setPosition(Vec2(x / 4, y / 4));
|
2016-04-25 19:43:42 +08:00
|
|
|
white->setIgnoreAnchorPointForPosition(false);
|
2021-12-28 16:06:23 +08:00
|
|
|
white->setPosition(Vec2(x / 4 * 3, y / 4 * 3));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
addChild(blue, -1);
|
|
|
|
addChild(white);
|
|
|
|
addChild(green);
|
|
|
|
addChild(red);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto rot = RotateBy::create(8, 720);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
blue->runAction(rot);
|
2013-06-19 07:12:28 +08:00
|
|
|
red->runAction(rot->clone());
|
|
|
|
green->runAction(rot->clone());
|
|
|
|
white->runAction(rot->clone());
|
2010-08-23 13:58:57 +08:00
|
|
|
}
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
bool RotateWorldTest::init()
|
2010-08-23 13:58:57 +08:00
|
|
|
{
|
2015-04-03 14:31:03 +08:00
|
|
|
if (TestCase::init())
|
|
|
|
{
|
|
|
|
auto layer = RotateWorldMainLayer::create();
|
2010-08-23 13:58:57 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
addChild(layer);
|
2019-09-24 11:31:35 +08:00
|
|
|
runAction(RotateBy::create(4.0f, -360.0f));
|
2010-08-23 13:58:57 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
return true;
|
|
|
|
}
|
2010-08-23 13:58:57 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
return false;
|
2010-08-23 13:58:57 +08:00
|
|
|
}
|