2012-04-08 14:16:29 +08:00
|
|
|
#include "RotateWorldTest.h"
|
|
|
|
#include "../testResource.h"
|
|
|
|
|
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
|
|
|
|
|
|
|
float x,y;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
x = size.width;
|
|
|
|
y = size.height;
|
|
|
|
|
|
|
|
//CCMutableArray *array = [UIFont familyNames];
|
2013-06-20 14:17:10 +08:00
|
|
|
//for( String *s in array )
|
2012-04-19 14:35:52 +08:00
|
|
|
// NSLog( s );
|
2013-06-20 14:17:10 +08:00
|
|
|
LabelTTF* label = LabelTTF::create("cocos2d", "Tahoma", 64);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-10-23 17:48:50 +08:00
|
|
|
label->setPosition( ccp(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
|
|
|
|
|
|
|
float x,y;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
x = size.width;
|
|
|
|
y = size.height;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* sprite = Sprite::create(s_pPathGrossini);
|
|
|
|
Sprite* spriteSister1 = Sprite::create(s_pPathSister1);
|
|
|
|
Sprite* spriteSister2 = Sprite::create(s_pPathSister2);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
sprite->setScale(1.5f);
|
|
|
|
spriteSister1->setScale(1.5f);
|
|
|
|
spriteSister2->setScale(1.5f);
|
|
|
|
|
2012-10-23 17:48:50 +08:00
|
|
|
sprite->setPosition(ccp(x/2,y/2));
|
|
|
|
spriteSister1->setPosition(ccp(40,y/2));
|
|
|
|
spriteSister2->setPosition(ccp(x-40,y/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Action *rot = RotateBy::create(16, -3600);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
addChild(sprite);
|
|
|
|
addChild(spriteSister1);
|
|
|
|
addChild(spriteSister2);
|
|
|
|
|
|
|
|
sprite->runAction(rot);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval *jump1 = JumpBy::create(4, ccp(-400,0), 100, 4);
|
|
|
|
ActionInterval *jump2 = jump1->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval *rot1 = RotateBy::create(4, 360*2);
|
|
|
|
ActionInterval *rot2 = rot1->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
spriteSister1->runAction(Repeat::create( Sequence::create(jump2, jump1, NULL), 5 ));
|
|
|
|
spriteSister2->runAction(Repeat::create( Sequence::create(jump1->clone(), jump2->clone(), NULL), 5 ));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
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
|
|
|
}
|
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
|
|
|
|
|
|
|
float x,y;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
x = size.width;
|
|
|
|
y = size.height;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Node* blue = LayerColor::create(ccc4(0,0,255,255));
|
|
|
|
Node* red = LayerColor::create(ccc4(255,0,0,255));
|
|
|
|
Node* green = LayerColor::create(ccc4(0,255,0,255));
|
|
|
|
Node* white = LayerColor::create(ccc4(255,255,255,255));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
blue->setScale(0.5f);
|
2012-10-23 17:48:50 +08:00
|
|
|
blue->setPosition(ccp(-x/4,-y/4));
|
2012-06-14 15:13:16 +08:00
|
|
|
blue->addChild( SpriteLayer::create() );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
red->setScale(0.5f);
|
2012-10-23 17:48:50 +08:00
|
|
|
red->setPosition(ccp(x/4,-y/4));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
green->setScale(0.5f);
|
2012-10-23 17:48:50 +08:00
|
|
|
green->setPosition(ccp(-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);
|
2012-06-12 16:22:25 +08:00
|
|
|
white->setPosition(ccp(x/4,y/4));
|
2012-06-15 15:10:40 +08:00
|
|
|
white->ignoreAnchorPointForPosition(false);
|
2012-06-12 16:22:25 +08:00
|
|
|
white->setPosition(ccp(x/4*3,y/4*3));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
addChild(blue, -1);
|
|
|
|
addChild(white);
|
|
|
|
addChild(green);
|
|
|
|
addChild(red);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Action* rot = RotateBy::create(8, 720);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void RotateWorldTestScene::runThisTest()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = RotateWorldMainLayer::create();
|
2010-08-23 13:58:57 +08:00
|
|
|
|
|
|
|
addChild(pLayer);
|
2013-06-20 14:17:10 +08:00
|
|
|
runAction( RotateBy::create(4, -360) );
|
2010-08-23 13:58:57 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(this);
|
2010-08-23 13:58:57 +08:00
|
|
|
|
|
|
|
}
|