Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // SplashScene.cpp
- #include "SplashScene.h"
- USING_NS_CC;
- CCScene* Splash::scene()
- {
- // 'scene' is an autorelease object
- CCScene *scene = CCScene::node();
- // 'layer' is an autorelease object
- Splash *layer = Splash::node();
- // add layer as a child to scene
- scene->addChild(layer);
- // return the scene
- return scene;
- }
- // on "init" you need to initialize your instance
- bool Splash::init()
- {
- //////////////////////////////
- // 1. super init first
- if ( !CCLayer::init() )
- {
- return false;
- }
- // 2. add a menu item with "X" image, which is clicked to quit the program
- // you may modify it.
- // add a "close" icon to exit the progress. it's an autorelease object
- CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(
- "CloseNormal.png",
- "CloseSelected.png",
- this,
- menu_selector(Splash::menuCloseCallback) );
- pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
- // create menu, it's an autorelease object
- CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
- pMenu->setPosition( CCPointZero );
- this->addChild(pMenu, 1);
- /////////////////////////////
- // 3. Do Splash Screen
- //
- // ask director the window size
- CCSize size = CCDirector::sharedDirector()->getWinSize();
- // add "Intro" splash screen"
- // position the sprite on the center of the screen
- // add the sprite as a child to this layer
- CCSprite* titleSprite = CCSprite::spriteWithFile("Intro.png");
- titleSprite->setPosition( ccp(size.width/2, size.height/2) );
- this->addChild(titleSprite, 0);
- //[NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(splashTimerCallback) userInfo:nil repeats:NO];
- /*
- int maxDuration = (int)4.0 //!!CC2DXHALP!!
- splashTimer = timer(4.0, *this, &timercb, NULL, false);
- CCFiniteTimeAction* runFadeout =
- CCCallFuncN::actionWithTarget( this,
- callfuncN_selector(Splash::spriteMoveFinished));
- target->runAction( CCSequence::actions(runFadeout, NULL));*/
- return true;
- }
- void Splash::menuCloseCallback(CCObject* pSender)
- {
- CCDirector::sharedDirector()->runWithScene(disclaimerScene); //!!CC2DXHALP!!
- #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
- exit(0);
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement