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()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLayer::onEnter();
|
|
|
|
|
|
|
|
float x,y;
|
|
|
|
|
|
|
|
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
x = size.width;
|
|
|
|
y = size.height;
|
|
|
|
|
|
|
|
//CCMutableArray *array = [UIFont familyNames];
|
|
|
|
//for( CCString *s in array )
|
|
|
|
// NSLog( s );
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF* label = CCLabelTTF::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()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLayer::onEnter();
|
|
|
|
|
|
|
|
float x,y;
|
|
|
|
|
|
|
|
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
x = size.width;
|
|
|
|
y = size.height;
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSprite* sprite = CCSprite::create(s_pPathGrossini);
|
|
|
|
CCSprite* spriteSister1 = CCSprite::create(s_pPathSister1);
|
|
|
|
CCSprite* spriteSister2 = CCSprite::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
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCAction *rot = CCRotateBy::create(16, -3600);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
addChild(sprite);
|
|
|
|
addChild(spriteSister1);
|
|
|
|
addChild(spriteSister2);
|
|
|
|
|
|
|
|
sprite->runAction(rot);
|
|
|
|
|
2012-10-23 17:48:50 +08:00
|
|
|
CCActionInterval *jump1 = CCJumpBy::create(4, ccp(-400,0), 100, 4);
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval *jump2 = jump1->reverse();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval *rot1 = CCRotateBy::create(4, 360*2);
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval *rot2 = rot1->reverse();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
spriteSister1->runAction(CCRepeat::create( CCSequence::create(jump2, jump1, NULL), 5 ));
|
|
|
|
spriteSister2->runAction(CCRepeat::create( CCSequence::create((CCFiniteTimeAction *)(jump1->copy()->autorelease()), (CCFiniteTimeAction *)(jump2->copy()->autorelease()), NULL), 5 ));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
spriteSister1->runAction(CCRepeat::create( CCSequence::create(rot1, rot2, NULL), 5 ));
|
|
|
|
spriteSister2->runAction(CCRepeat::create( CCSequence::create((CCFiniteTimeAction *)(rot2->copy()->autorelease()), (CCFiniteTimeAction *)(rot1->copy()->autorelease()), 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()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLayer::onEnter();
|
|
|
|
|
|
|
|
float x,y;
|
|
|
|
|
|
|
|
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
x = size.width;
|
|
|
|
y = size.height;
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCNode* blue = CCLayerColor::create(ccc4(0,0,255,255));
|
|
|
|
CCNode* red = CCLayerColor::create(ccc4(255,0,0,255));
|
|
|
|
CCNode* green = CCLayerColor::create(ccc4(0,255,0,255));
|
|
|
|
CCNode* white = CCLayerColor::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);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCAction* rot = CCRotateBy::create(8, 720);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
blue->runAction(rot);
|
|
|
|
red->runAction((CCAction *)(rot->copy()->autorelease()));
|
|
|
|
green->runAction((CCAction *)(rot->copy()->autorelease()) );
|
|
|
|
white->runAction((CCAction *)(rot->copy()->autorelease()) );
|
2010-08-23 13:58:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void RotateWorldTestScene::runThisTest()
|
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLayer* pLayer = RotateWorldMainLayer::create();
|
2010-08-23 13:58:57 +08:00
|
|
|
|
|
|
|
addChild(pLayer);
|
2012-06-14 15:13:16 +08:00
|
|
|
runAction( CCRotateBy::create(4, -360) );
|
2010-08-23 13:58:57 +08:00
|
|
|
|
2010-11-11 11:18:58 +08:00
|
|
|
CCDirector::sharedDirector()->replaceScene(this);
|
2010-08-23 13:58:57 +08:00
|
|
|
|
|
|
|
}
|