在Android设备上退出Libgdx应用程序

时间:2016-07-29 13:26:11

标签: android libgdx

当我在Android设备上通过Gdx.app.exit()退出游戏时,它会给我App已停止消息

这是退出libgdx应用程序的正确方法吗?

以这种方式处置资产吗?我将Assets.dispose()放在我的游戏类dispose()方法

它给了我这个例外

java.lang.NullPointerException at com.badlogic.gdx.backends.android.AndroidInput.lookUpPointerIndex(AndroidInput.java:802) at com.badlogic.gdx.backends.android.AndroidMultiTouchHandler.onTouch(AndroidMultiTouchHandler.java:64) at com.badlogic.gdx.backends.android.AndroidInput.onTouch(AndroidInput.java:429) at android.view.View.dispatchTouchEvent(View.java:7793) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2287) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2287) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2287) at android.view.ViewGroup.cancelAndClearTouchTargets(ViewGroup.java:2128) at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2686) at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:3201) at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5810) at android.view.ViewRootImpl.die(ViewRootImpl.java:5783) at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:348) at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:303) at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3776) at android.app.ActivityThread.access$1500(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1407) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:5345) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644) at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:0)

问题出在InputListener的touchDown()方法中,我用addListener来退出按钮 我用ClickListener的clicked()替换了它,它解决了问题