Change splash screen

Change splash screen

I read a lot of answers in the forum about how to change the coco2d splash screen when the application runs in an iOS mobile.I tried everything, but I can not make it work.

Anyone can help me? When the application runs, the coco2d logo appears. I need to change that logo for another. Need I add code in AppDelegate or can I find the image.png that appears and replace it with another… ?

Anyone have an example?
Thanks a lot.

I replaced the images “Default” png located in proj.ios_mac / ios and it works. But how can I scale the image ? Where is the part of code that load this images?

As fas as I know, you can’t manipulate this since the Xcode/iOS itself is integrating it. What you can do is create a SplashScene and display a Sprite object that will serve as your splash image.

@macmoy thanks for the answer. But, how to do that?
I created the method “drawSplashScreen” into my “Game” class.

void Game::drawSplashScreen()
    auto visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    Sprite *splashScreen = Sprite::create("Default.png");
    splashScreen->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height/2));
    float visSizeX = Director::getInstance()->getVisibleSize().width;
    float bgWidth = splashScreen->getContentSize().width;
    float targetSmallSquareWidth = visSizeX * 0.70f;
    float scaleFactorX = targetSmallSquareWidth / bgWidth;
    float visSizeY = Director::getInstance()->getVisibleSize().height;
    float bgHeight = splashScreen->getContentSize().height;
    float targetSmallSquareHeight = visSizeY * 0.15f;
    float scaleFactorY = targetSmallSquareHeight / bgHeight;
    if (Director::getInstance()->getOpenGLView())

After that, I call the method in AppDelegate.cpp (applicationDidFinishLaunching method) just before of director->runWithScene(scene); but It does not work.

What is my error?
I read opinions about modify CCDirector class but I don’t want to do that because if cocos2d is upgraded I need remember always modify the class…

I’m not sure what you’re trying to achieve from your code. I believe you are doing a bit of overwork just to display a splash image. You can use the cocos2d-x Scene Graph to display the image instead of manually swapping the GL buffers.

here’s a snippet:

Sprite *splashScreen = Sprite::create("Default.png");
splashScreen->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height/2));

This code will work as long as your ‘Game’ class inherits to at least cocos2d::Node.

@macmoy thanks for the answer. But, where should I put that code?
My problem is not how to create an image on the scene, else how to replace the default splash coco2d image when application runs. This image:


Named “Default.png” Located in “proj.ios_mac/ios” folder is the image that loads by default when application runs. My question is: where is the code that loads that image? I can replace the image by another one with the same name, my problem is that I need scale it, and for do that I need know where is the code that load the image, or find another alternative.


As far as I know, we cannot customize how it works as I think it’s integrated in iOS. My workaround for this is make that image a blank black image (or whatever color you want) then make a Scene that will become your Splash screen. In the class, you can do whatever you want. To illustrate, see below:

you open the app --> black image appears (Default.png) --> Splash class will open (custom class you made)

As @macmoy mentioned. This file is loaded by iOS without any code from your app. You can read more about it here. In short: iOS shows this launch screen and after that, it will execute your app code.

PS: The same can be found in Android as described here.

Thanks for the answers!
I thought I could replace this coco2d image, however @macmoy your solution is very good.
Thanks again!

No problem @tranthor. Don’t forget to mark it as a solution so others can immediately see it. Happy Coding!

Hey peter , just wanted to know how can i add splash screen without adding a scene at the start of the game . and also i need to disable all the libraries that i am not using so that app size can be reduced , i tried removing some and also physics though i am not using physics its giving me some error, I am using the JS version of cocos. Any help will be appreciable .

Please start a new topic. This topic is 2 years old and not a JS thread.