axmol/tests/cpp-tests/Classes/RotateWorldTest/RotateWorldTest.cpp

137 lines
3.5 KiB
C++
Raw Normal View History

#include "RotateWorldTest.h"
#include "../testResource.h"
2010-08-23 13:58:57 +08:00
//------------------------------------------------------------------
//
// TestLayer
//
//------------------------------------------------------------------
void TestLayer::onEnter()
{
Layer::onEnter();
float x,y;
auto size = Director::getInstance()->getWinSize();
x = size.width;
y = size.height;
//auto array = [UIFont familyNames];
//for( String *s in array )
// NSLog( s );
auto label = Label::createWithSystemFont("cocos2d", "Tahoma", 64);
2013-07-12 14:11:55 +08:00
label->setPosition( Point(x/2,y/2) );
addChild(label);
2010-08-23 13:58:57 +08:00
}
//------------------------------------------------------------------
//
// SpriteLayer
//
//------------------------------------------------------------------
void SpriteLayer::onEnter()
{
Layer::onEnter();
float x,y;
auto size = Director::getInstance()->getWinSize();
x = size.width;
y = size.height;
auto sprite = Sprite::create(s_pathGrossini);
auto spriteSister1 = Sprite::create(s_pathSister1);
auto spriteSister2 = Sprite::create(s_pathSister2);
sprite->setScale(1.5f);
spriteSister1->setScale(1.5f);
spriteSister2->setScale(1.5f);
2013-07-12 14:11:55 +08:00
sprite->setPosition(Point(x/2,y/2));
spriteSister1->setPosition(Point(40,y/2));
spriteSister2->setPosition(Point(x-40,y/2));
auto rot = RotateBy::create(16, -3600);
addChild(sprite);
addChild(spriteSister1);
addChild(spriteSister2);
sprite->runAction(rot);
auto jump1 = JumpBy::create(4, Point(-400,0), 100, 4);
auto jump2 = jump1->reverse();
auto rot1 = RotateBy::create(4, 360*2);
auto rot2 = rot1->reverse();
spriteSister1->runAction(Repeat::create( Sequence::create(jump2, jump1, NULL), 5 ));
spriteSister2->runAction(Repeat::create( Sequence::create(jump1->clone(), jump2->clone(), NULL), 5 ));
spriteSister1->runAction(Repeat::create( Sequence::create(rot1, rot2, NULL), 5 ));
spriteSister2->runAction(Repeat::create( Sequence::create(rot2->clone(), rot1->clone(), NULL), 5 ));
2010-08-23 13:58:57 +08:00
}
2010-08-23 13:58:57 +08:00
//------------------------------------------------------------------
//
// RotateWorldMainLayer
//
//------------------------------------------------------------------
2010-08-23 13:58:57 +08:00
void RotateWorldMainLayer::onEnter()
{
Layer::onEnter();
float x,y;
auto size = Director::getInstance()->getWinSize();
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));
blue->setScale(0.5f);
2013-07-12 14:11:55 +08:00
blue->setPosition(Point(-x/4,-y/4));
blue->addChild( SpriteLayer::create() );
red->setScale(0.5f);
2013-07-12 14:11:55 +08:00
red->setPosition(Point(x/4,-y/4));
green->setScale(0.5f);
2013-07-12 14:11:55 +08:00
green->setPosition(Point(-x/4,y/4));
green->addChild(TestLayer::create());
white->setScale(0.5f);
2013-07-12 14:11:55 +08:00
white->setPosition(Point(x/4,y/4));
white->ignoreAnchorPointForPosition(false);
2013-07-12 14:11:55 +08:00
white->setPosition(Point(x/4*3,y/4*3));
addChild(blue, -1);
addChild(white);
addChild(green);
addChild(red);
auto rot = RotateBy::create(8, 720);
blue->runAction(rot);
red->runAction(rot->clone());
green->runAction(rot->clone());
white->runAction(rot->clone());
2010-08-23 13:58:57 +08:00
}
void RotateWorldTestScene::runThisTest()
{
auto layer = RotateWorldMainLayer::create();
2010-08-23 13:58:57 +08:00
addChild(layer);
runAction( RotateBy::create(4, -360) );
2010-08-23 13:58:57 +08:00
Director::getInstance()->replaceScene(this);
2010-08-23 13:58:57 +08:00
}