How to create android cocos2dx splash screen?

前端 未结 4 770
余生分开走
余生分开走 2021-01-15 17:27

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

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 17:40

    try this link out maybe you can find something useful here http://www.androidhive.info/2013/07/how-to-implement-android-splash-screen-2/

    #include "HelloWorldScene.h" 
    #include "OptionsScene.h" 
    #include "SplashScene.h" 
    #include "SimpleAudioEngine.h" 
    #include "RedirectMethods.h" 
    
    using namespace cocos2d;
    using namespace CocosDenshion;
    
    CCScene* SplashScene::scene() {
        CCScene *scene = CCScene::create();
        SplashScene *layer = SplashScene::create();
        scene->addChild(layer);
        return scene;
    }
    
    bool SplashScene::init() {
        if (!CCLayer::init()) {
            return false;
        }
    
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
    
        CCSprite* logomarca = CCSprite::create("cocos2dx_logo.png");
        logomarca->setPosition(ccp(screenSize.width / 2, screenSize.height / 2));
        this->addChild(logomarca, 1);
    
        CCFiniteTimeAction *seq1 = CCSequence::create(CCDelayTime::create(3.0),
                CCCallFuncN::create(this,
                        callfuncN_selector(RedirectMethods::MenuScene)), NULL);
    
        this->runAction(seq1);
    
        return true;
    }
    

    or try this one i hope it will solve it

提交回复
热议问题