Advertisement
Guest User

Untitled

a guest
Jul 21st, 2011
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.26 KB | None | 0 0
  1. //
  2. //  SplashScene.cpp
  3.  
  4. #include "SplashScene.h"
  5.  
  6. USING_NS_CC;
  7.  
  8. CCScene* Splash::scene()
  9. {
  10.     // 'scene' is an autorelease object
  11.     CCScene *scene = CCScene::node();
  12.    
  13.     // 'layer' is an autorelease object
  14.     Splash *layer = Splash::node();
  15.  
  16.     // add layer as a child to scene
  17.     scene->addChild(layer);
  18.  
  19.     // return the scene
  20.     return scene;
  21. }
  22.  
  23. // on "init" you need to initialize your instance
  24. bool Splash::init()
  25. {
  26.     //////////////////////////////
  27.     // 1. super init first
  28.     if ( !CCLayer::init() )
  29.     {
  30.         return false;
  31.     }
  32.     // 2. add a menu item with "X" image, which is clicked to quit the program
  33.     //    you may modify it.
  34.  
  35.     // add a "close" icon to exit the progress. it's an autorelease object
  36.     CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(
  37.                                         "CloseNormal.png",
  38.                                         "CloseSelected.png",
  39.                                         this,
  40.                                         menu_selector(Splash::menuCloseCallback) );
  41.     pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
  42.  
  43.     // create menu, it's an autorelease object
  44.     CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
  45.     pMenu->setPosition( CCPointZero );
  46.     this->addChild(pMenu, 1);
  47.  
  48.     /////////////////////////////
  49.     // 3. Do Splash Screen
  50.     //
  51.     // ask director the window size
  52.     CCSize size = CCDirector::sharedDirector()->getWinSize();
  53.  
  54.     // add "Intro" splash screen"
  55.     // position the sprite on the center of the screen
  56.     // add the sprite as a child to this layer
  57.     CCSprite* titleSprite = CCSprite::spriteWithFile("Intro.png");
  58.     titleSprite->setPosition( ccp(size.width/2, size.height/2) );
  59.     this->addChild(titleSprite, 0);
  60.     //[NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(splashTimerCallback) userInfo:nil repeats:NO];
  61.    
  62.     /*
  63.     int maxDuration = (int)4.0  //!!CC2DXHALP!!
  64.  
  65.     splashTimer = timer(4.0, *this, &timercb, NULL, false);
  66.  
  67.     CCFiniteTimeAction* runFadeout =
  68.          CCCallFuncN::actionWithTarget( this,
  69.          callfuncN_selector(Splash::spriteMoveFinished));
  70.  
  71.     target->runAction( CCSequence::actions(runFadeout, NULL));*/
  72.  
  73.     return true;
  74. }
  75.  
  76. void Splash::menuCloseCallback(CCObject* pSender)
  77. {
  78.     CCDirector::sharedDirector()->runWithScene(disclaimerScene);  //!!CC2DXHALP!!
  79.  
  80. #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
  81.     exit(0);
  82. #endif
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement