Load screen for android

Load screen for android
0

#1

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


#2

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


#3

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


#4

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


#5

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


#6

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


#7

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


#8

I don’t understand this.


#9

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


#10

There are several threads on this:


#11

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.


#12

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


#13

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?


#14

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