Load screen for android

so i want to show my logo while game load. how can i do that ?

First show the logo, then let cocos draw, then start loading

what do you mean by let cocos draw ? and can you give example

This just came up in another topic a week or two ago. You can use your custom logo instead of the Cocos Creator logo…

can you send the link to how to do that would be the best

search these forums too. This is answered a few times.

well there isn’t a splash png jsb-default file

I don’t understand this.

well im building for android not web and jsb-default file which is for native build doesn’t have a splash.png file inside of it that i can change

There are several threads on this:

2 Likes

You should set some stuffs manually in your project default build folder. Follow these steps:

  1. Put your load screen PNG file in a folder of /res. Eg.: /proj.android-studio/app/res/drawable/mylogo.png
  2. Create a launch screen XML file to load the PNG file. Name it as launch_screen.xml and put the XML file in the same folder of PNG file.
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
  
  <!-- The background colour -->
  <item android:drawable="@android:color/black"/>
  
  <!-- Your splash file - your png file name without extension-->
  <item>
    <bitmap
      android:src="@drawable/mylogo"
      android:gravity="center"/>
  </item>
  
</layer-list>
  1. Create styles.xml in proj.android-studio/app/res/values/styles.xml. Item section should refer to launch screen XML file at step 2.
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="AppTheme" parent="@android:style/Theme.NoTitleBar.Fullscreen">
    <item name="android:windowBackground">@drawable/launch_screen</item>
  </style>
  
</resources>
  1. Find activity section in AndroidManifest.xml. Replace android:theme parameter, refer to the style name parameter in styles.xml at step 3.
...
       <activity
            android:name="org.cocos2dx.javascript.AppActivity"
            android:screenOrientation="portrait"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/AppTheme"
            android:launchMode="singleTask"
            android:taskAffinity="" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
...
  1. Last step. Edit AppActivity.java. You can find it in /proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java. Find onCreate method and call setTheme function. You should call setTheme function before super.onCreate command. Please use your app package name to get R.style property. R.style property should refer to the style name parameter as in styles.xml at step 3.
...
protected void onCreate(Bundle savedInstanceState) {
        setTheme([your app Package Name].R.style.AppTheme);
        super.onCreate(savedInstanceState);
        // Workaround in https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508
        if (!isTaskRoot()) {
            // Android launched another instance of the root activity into an existing task
            //  so just quietly finish and go away, dropping the user back into the activity
            //  at the top of the stack (ie: the last state of this task)
            // Don't need to finish it again since it's finished in super.onCreate .
            return;
        }
        // DO OTHER INITIALIZATION BELOW
        
        SDKWrapper.getInstance().init(this);
        CAAgent.enableDebug(false);
    }
...

Hope it’ll help.

2 Likes

Hey, Thanks for the reply. haven’t tried yet had exams I will hopefully today.

Hi!
I’ve tried this method.

It doesn’t show image on Android 4.4.2
It show image and switches to black again on Android 8.0.0

Do we have any workaround?

damn 1 month passed and i still havent tested it :smiley:

ok so any ideas how i add a background color cuz imma add logo of my company name and i want background to be a specific color?

@FocusCreative have u found a solution ?

I cancelled to use this method. I’ve made a simple scene with logo. Game starts with logo scene and it has acceptable loading time for me. 1-3 secs black screen for new phones.

1 Like

can you show me your code for changing from load screen to game

Sure!

First I created an empty scene:
image

I put my logo center of canvas:

Added a node “Load_Home_Screen” to switch to next scene onLoad.

Put a script on it to load next scene:

cc.Class({
    extends: cc.Component,

    properties: {

    },

    onLoad () {

        cc.director.preloadScene("Intro_Screen");
        cc.director.loadScene("Intro_Screen");

    },

});

I selected logo scene as start scene:
image

If you call “preloadScene()” before “loadScene()” then it preloads the next scene and stays in logo scene until next scene is ready to show.

Hope it helps!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.