我有一个 main.lua,它告诉我的应用程序转到另一个场景(intro.lua),这是一个视频播放,视频播放完毕后,我想转到第三个场景,即我的游戏菜单(菜单.lua)。
问题是我的 Android 应用程序在视频完成后停止。它不会进入“菜单”场景。
我的代码如下:
我的 main.lua:
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
system.setIdleTimer( false )
display.setStatusBar( display.HiddenStatusBar )
yourName=""
labName=""
titleName=""
rememberMusic=1
rememberSound=1
remeberMusicSlider=300
remeberSoundSlider=300
sndMusic = audio.loadStream ( "Audio/ambient.mp3" )
sndClick = audio.loadStream ( "Audio/click.mp3" )
storyboard.gotoScene("intro")
return scene
我的视频介绍.lua:
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
system.setIdleTimer( false )
display.setStatusBar( display.HiddenStatusBar )
local onComplete = function()
storyboard.gotoScene("menu")
end
media.playVideo( "videos/logo.mp4", false, onComplete )
return scene
我的 menu.lua 很大,我不能在这里发布。但它没有问题。如果我从 main.lua 调用它,它会很好用。如果我从我的 intro.lua 中调用它(没有视频),效果很好。
但是如果我调用它(如上面代码中所写),当视频完成时,应用程序就会停止。
有人知道发生了什么吗?
来自 Eclipse 的错误:
07-05 17:52:22.111: W/dalvikvm(448): threadid=1: thread exiting with uncaught exception (group=0x410f5930)
07-05 17:52:22.121: E/AndroidRuntime(448): FATAL EXCEPTION: main
07-05 17:52:22.121: E/AndroidRuntime(448): java.lang.NullPointerException
07-05 17:52:22.121: E/AndroidRuntime(448): at com.ansca.corona.VideoActivity$1.onCompletion(VideoActivity.java:48)
07-05 17:52:22.121: E/AndroidRuntime(448): at android.widget.VideoView$3.onCompletion(VideoView.java:361)
07-05 17:52:22.121: E/AndroidRuntime(448): at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1980)
07-05 17:52:22.121: E/AndroidRuntime(448): at android.os.Handler.dispatchMessage(Handler.java:99)
07-05 17:52:22.121: E/AndroidRuntime(448): at android.os.Looper.loop(Looper.java:137)
07-05 17:52:22.121: E/AndroidRuntime(448): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-05 17:52:22.121: E/AndroidRuntime(448): at java.lang.reflect.Method.invokeNative(Native Method)
07-05 17:52:22.121: E/AndroidRuntime(448): at java.lang.reflect.Method.invoke(Method.java:511)
07-05 17:52:22.121: E/AndroidRuntime(448): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-05 17:52:22.121: E/AndroidRuntime(448): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-05 17:52:22.121: E/AndroidRuntime(448): at dalvik.system.NativeStart.main(Native Method)
07-05 17:52:22.131: W/ActivityManager(478): Force finishing activity com.demigod.biolab/com.ansca.corona.VideoActivity
07-05 17:52:22.271: D/dalvikvm(478): GC_FOR_ALLOC freed 708K, 29% free 17351K/24288K, paused 110ms, total 112ms
07-05 17:52:22.791: W/ActivityManager(478): Activity pause timeout for ActivityRecord{41e855c0 u0 com.demigod.biolab/com.ansca.corona.VideoActivity}
07-05 17:52:22.981: I/hwcomposer(125): Setting interactive mode: On
07-05 17:52:32.291: W/ActivityManager(478): Launch timeout has expired, giving up wake lock!
07-05 17:52:32.801: W/ActivityManager(478): Activity idle timeout for ActivityRecord{41ccb8d8 u0 com.demigod.biolab/com.ansca.corona.CoronaActivity}