title: How to create android cocos2dx splash screen?
body: <p>This is my code I don't know how to create splash screen and how it will direct in my menu screen. All .h must be connected to BaseScreen and the BaseScreen will be the one connected in cocos2d layer. please help me in my codes. Do only thing that appears in my emulator is the sprite which I code in HelloWorldScreen.h</p>
  
  <p><strong>SplashScreen.h</strong></p>
  
  <pre><code>ifndef __SPLASH_SCREEN_H__
  define __SPLASH_SCREEN_H__
  
  include "BaseScreen.h"
  include "cocos2d.h"
  
  class SplashScreen : BaseScreen 
  {
  public:
  void update ();
  static cocos2d::CCSprite* splashScreen;
  int time;
  MenuScreen menuScreen;
  };
  endif
  </code></pre>
  
  <hr>
  
  <p><strong>HelloWorldScene.cpp</strong></p>
  
  <pre><code>include "HelloWorldScene.h"
  include "SplashScreen.h"
  include "cocos2d.h"
  
  USING_NS_CC;
  
  CCScene* HelloWorld::scene()
  {
  // 'scene' is an autorelease object
  CCScene *scene = CCScene::create();
  
  // 'layer' is an autorelease object
  HelloWorld *layer = HelloWorld::create();
  
  // add layer as a child to scene
  scene-&gt;addChild(layer);
  
  // return the scene
  return scene;
  }
  
  // on "init" you need to initialize your instance
  bool HelloWorld::init()
  {
  
  // 1. super init first
  if ( !CCLayer::init() )
  {
      return false;
  }
  
  CCSize winSize = CCDirector::sharedDirector()-&gt;getWinSize();
  CCSize size = CCDirector::sharedDirector()-&gt;getWinSize();
  CCSize visibleSize = CCDirector::sharedDirector()-&gt;getVisibleSize();
  CCPoint origin = CCDirector::sharedDirector()-&gt;getVisibleOrigin();
  
  
  // 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::create(
                                      "CloseNormal.png",
                                      "CloseSelected.png",
                                      this,
                                      menu_selector(HelloWorld::menuCloseCallback));
  
  pCloseItem-&gt;setPosition(ccp(origin.x + visibleSize.width -                       pCloseItem-&gt;getContentSize().width/2 ,
                              origin.y + pCloseItem-&gt;getContentSize().height/2));
  
  // create menu, it's an autorelease object
  CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
  pMenu-&gt;setPosition(CCPointZero);
  this-&gt;addChild(pMenu, 1);
  
  
  // 3. add your codes below...
  
  // create background image from png
      CCSprite *splashScreen = CCSprite::create("company.png");
      // position the background image at the center of window
      splashScreen-&gt;setPosition(ccp(size.width / 2, size.height / 2));
  
  
      // add background image at z-position = -1, bottom of all
      this-&gt;addChild(splashScreen, -1);
  
      // calculate the scaling factor to fill the window size
      float bX = size.width / splashScreen-&gt;getContentSize().width;
      float bY = size.height / splashScreen-&gt;getContentSize().height;
  
      // set the scaling factor to the background image
      splashScreen-&gt;setScaleX(bX);
      splashScreen-&gt;setScaleY(bY);
  
  return true;
  }
  
  
  //callfuncN_selector(MainScene::spriteMoveFinished)
  //backcalls the function spriteMoveFinished()
  void HelloWorld::spriteMoveFinished(CCNode* pSender)
  {
  CCSprite *sprite = (CCSprite *)pSender;
  this-&gt;removeChild(sprite, true);
  }
  
  
  void HelloWorld::menuCloseCallback(CCObject* pSender)
  {
  CCDirector::sharedDirector()-&gt;end();
  
  if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
  exit(0);
  endif
  }
  </code></pre>
  
  <hr>
  
  <p><strong>BaseScreen.h</strong></p>
  
  <pre><code>ifndef __BASE_SCREEN_H__
  define __BASE_SCREEN_H__
  
  include "cocos2d.h"
  
  class BaseScreen : public cocos2d::CCLayer
  {
  public:
  //  BaseScreen getParent ();
  void loadNewScreen (BaseScreen newScreen);
  void update ();
  //  BaseScreen *parentBaseScene;
  };
  endif
  </code></pre>