make cocos2dxhelper static

This commit is contained in:
qimiko committed 2022-05-27 22:49:08 -07:00
1 parent 28c0007d14
commit a2279f7b2c
1 file changed
+12 -15
@@ -1,23 +1,21 @@
package org.cocos2dx.lib package org.cocos2dx.lib
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.pm.ApplicationInfo import android.content.pm.ApplicationInfo
import android.os.Process import android.os.Process
@Suppress("unused") @Suppress("unused", "KotlinJniMissingFunction")
class Cocos2dxHelper { object Cocos2dxHelper {
companion object { // private val sCocos2dMusic: Cocos2dxMusic? = null
// private val sCocos2dMusic: Cocos2dxMusic? = null
// private val sCocos2dSound: Cocos2dxSound? = null // private val sCocos2dSound: Cocos2dxSound? = null
// private val sAssetManager: AssetManager? = null // private val sAssetManager: AssetManager? = null
// private val sCocos2dxAccelerometer: Cocos2dxAccelerometer? = null // private val sCocos2dxAccelerometer: Cocos2dxAccelerometer? = null
// private val sAccelerometerEnabled = false // private val sAccelerometerEnabled = false
private var sPackageName: String? = null private var sPackageName: String? = null
private var sFileDirectory: String? = null private var sFileDirectory: String? = null
@SuppressLint("StaticFieldLeak")
private var sContext: Context? = null // private var sContext: Context? = null
private var sCocos2dxHelperListener: Cocos2dxHelperListener? = null private var sCocos2dxHelperListener: Cocos2dxHelperListener? = null
@JvmStatic @JvmStatic
@@ -31,9 +29,14 @@ class Cocos2dxHelper {
return sFileDirectory return sFileDirectory
} }
@JvmStatic
fun terminateProcess() {
Process.killProcess(Process.myPid())
}
fun init(pContext: Context, pCocos2dxHelperListener: Cocos2dxHelperListener) { fun init(pContext: Context, pCocos2dxHelperListener: Cocos2dxHelperListener) {
val applicationInfo: ApplicationInfo = pContext.applicationInfo val applicationInfo: ApplicationInfo = pContext.applicationInfo
sContext = pContext // sContext = pContext
sCocos2dxHelperListener = pCocos2dxHelperListener sCocos2dxHelperListener = pCocos2dxHelperListener
sPackageName = applicationInfo.packageName sPackageName = applicationInfo.packageName
sFileDirectory = pContext.filesDir.absolutePath sFileDirectory = pContext.filesDir.absolutePath
@@ -51,12 +54,6 @@ class Cocos2dxHelper {
// Cocos2dxETCLoader.setContext(pContext) // Cocos2dxETCLoader.setContext(pContext)
} }
@JvmStatic
fun terminateProcess() {
Process.killProcess(Process.myPid())
}
}
interface Cocos2dxHelperListener { interface Cocos2dxHelperListener {
fun runOnGLThread(pRunnable: Runnable) fun runOnGLThread(pRunnable: Runnable)