After learning about the pause and resume events I decided to re-create the program using a different approach.
I designed it so the Main program will load the asset manager and create two screens for the screen manager. I then created two classes, one to handle each screen. The Main just acts as a message-pump and forwards the show/resize/etc. events to each class as necessary. Each class is initialized in the Show event for its screen.
At the start of the program, once the asset manager is done loading, I can initially display screen one or screen two with no errors.
If I display screen one initially and then try to switch to screen two, I get an error compiling shader while initializing the screen two class:
The statement that causes the error is when I try to initialize the main stage for the screen (the stage and all groups/tables for the screen are declared in the class, not passed in); for example: MainStage.Initialize("MainEvent") where MainStage is defined as lgScn2DStage.
I'm sure there is something fundamental that I'm not understanding or thread rule that I'm breaking that I don't know about but for the life of me I can't track it down.
Any suggestions would be most welcome!
Thanks in advance,
- Richard
I designed it so the Main program will load the asset manager and create two screens for the screen manager. I then created two classes, one to handle each screen. The Main just acts as a message-pump and forwards the show/resize/etc. events to each class as necessary. Each class is initialized in the Show event for its screen.
At the start of the program, once the asset manager is done loading, I can initially display screen one or screen two with no errors.
If I display screen one initially and then try to switch to screen two, I get an error compiling shader while initializing the screen two class:
B4X:
java.lang.IllegalArgumentException: Error compiling shader:
at com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader(SourceFile:157)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SourceFile:120)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SourceFile:77)
at anywheresoftware.b4a.libgdx.graphics.lgSpriteBatch.Initialize(SourceFile:29)
at com.badlogic.gdx.scenes.scene2d.Stage.<init>(SourceFile:130)
at anywheresoftware.b4a.libgdx.scene2d.lgStage.Initialize(SourceFile:38)
at phx.cards2.clscribscreen._initialize(clscribscreen.java:142)
at phx.cards2.main._gamescreen_show(main.java:501)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.libgdx.lgScreenManager$lgScreen.show(SourceFile:139)
at anywheresoftware.b4a.libgdx.lgScreenManager.setCurrentScreen(SourceFile:61)
at phx.cards2.main._titlescreen_class_play_click(main.java:746)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.keywords.Common$5.run(Common.java:952)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3689)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
java.lang.IllegalArgumentException: Error compiling shader:
I'm sure there is something fundamental that I'm not understanding or thread rule that I'm breaking that I don't know about but for the life of me I can't track it down.
Any suggestions would be most welcome!
Thanks in advance,
- Richard