Browse Source

1.修改icon
2.修改开机图

FailedToRead 3 years ago
parent
commit
2a9ee55afc

BIN
.idea/caches/build_file_checksums.ser


+ 5 - 6
app/build.gradle

@@ -25,13 +25,12 @@ android {
                                         project.file("G:/CocosCreator/cocoscreator_ide/CocosCreator_v2.4.0_20200622_win/resources/cocos2d-x/external")]
                     if (Os.isFamily(Os.FAMILY_WINDOWS)) {
                         arguments 'NDK_MODULE_PATH=' + module_paths.join(";")
-                    }
-                    else {
+                    } else {
                         arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
                     }
 
                     arguments '-j' + Runtime.runtime.availableProcessors()
-                    abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String})
+                    abiFilters.addAll(PROP_APP_ABI.split(':').collect { it as String })
                 }
             }
         }
@@ -55,7 +54,7 @@ android {
 
     signingConfigs {
 
-       release {
+        release {
             if (project.hasProperty("RELEASE_STORE_FILE")) {
                 storeFile file(RELEASE_STORE_FILE)
                 storePassword RELEASE_STORE_PASSWORD
@@ -128,8 +127,8 @@ android.applicationVariants.all { variant ->
 }
 
 dependencies {
-    implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
-    implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
+    implementation fileTree(dir: '../libs', include: ['*.jar', '*.aar'])
+    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
     implementation fileTree(dir: "G:/CocosCreator/cocoscreator_ide/CocosCreator_v2.4.0_20200622_win/resources/cocos2d-x/cocos/platform/android/java/libs", include: ['*.jar'])
     implementation project(':libcocos2dx')
 

BIN
res/drawable/icon.png


BIN
res/drawable/openimg.jpg


+ 7 - 0
src/org/cocos2dx/javascript/AppActivity.java

@@ -34,6 +34,7 @@ import android.os.Bundle;
 
 import android.content.Intent;
 import android.content.res.Configuration;
+import android.view.KeyEvent;
 import android.view.View;
 import android.view.WindowManager;
 import android.widget.FrameLayout;
@@ -177,4 +178,10 @@ public class AppActivity extends Cocos2dxActivity {
         SDKWrapper.getInstance().onStart();
         super.onStart();
     }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+//        return super.onKeyDown(keyCode, event);
+        return mPresenter.onKeyDown(keyCode, event);
+    }
 }

+ 30 - 1
src/org/cocos2dx/javascript/presenter/MainPresenter.java

@@ -1,6 +1,7 @@
 package org.cocos2dx.javascript.presenter;
 
-import android.view.View;
+import android.os.Process;
+import android.view.KeyEvent;
 import android.widget.Toast;
 
 import com.google.gson.Gson;
@@ -9,6 +10,7 @@ import org.cocos2dx.javascript.AppActivity;
 import org.cocos2dx.javascript.util.DeviceUtil;
 import org.cocos2dx.javascript.util.Logger;
 import org.cocos2dx.javascript.util.PackageUtil;
+import org.cocos2dx.lib.Cocos2dxJavascriptJavaBridge;
 
 public class MainPresenter {
     private static AppActivity mActivity;
@@ -69,4 +71,31 @@ public class MainPresenter {
 
     }
 
+
+    public static void exitApp() {
+        mActivity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mActivity.finish();
+                android.os.Process.killProcess(Process.myPid());
+            }
+        });
+    }
+
+
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        switch (keyCode) {
+            case KeyEvent.KEYCODE_BACK:
+            case KeyEvent.KEYCODE_ESCAPE:
+                mActivity.runOnGLThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        Cocos2dxJavascriptJavaBridge.evalString("PUBLIC.keyBack()");
+                    }
+                });
+                return true;
+        }
+        return false;
+    }
+
 }