Sub Process_Globals
End Sub
Sub Globals
    Dim lGdx As LibGDX
    Dim Surface As View
    Dim GL As lgGL
    Dim AM As lgAssetManager
    Dim Stage(2) As lgScn2DStage
    Dim Table(2) As lgScn2DTable
   
    Dim lGdx_ScrMgr As lgScreenManager
    Dim lGdx_Screen(2) As lgScreen
   
    Dim foComicFont As lgBitmapFont
    Dim lblScore As lgScn2DLabel
   
    Dim flTouchDown As Long
   
   
    Private panLoading As Panel
    ' ---- layLoading 
    Private lblLoadingHead As Label
    Private pgbLoading As ProgressBar
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Initializes libGDX
    Dim Config As lgConfiguration
    Config.useGL20 = True
    Config.useAccelerometer = False
    Config.useCompass = False
    Config.useWakelock = True
    Config.maxSimultaneousSounds = 6
    'Creates the LibGDX surface
    Surface = lGdx.InitializeView2(Config, "LG")
    Activity.AddView(Surface, 0,  0, 100%x, 100%y)
   
    'Create our loading screen   
    panLoading.Initialize("")
    Dim poCD As ColorDrawable
    poCD.Initialize(Colors.Black, 0)
    Activity.AddView(panLoading, 0, 0, 100%x, 100%y)
    panLoading.LoadLayout("layLoading")
    panLoading.Color = Colors.Black
    panLoading.Background = poCD
    panLoading.BringToFront
End Sub
Sub Activity_Resume
    'Informs libGDX of Resume events
    If lGdx.IsInitialized Then lGdx.Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
    'Informs libGDX of Pause events
    If lGdx.IsInitialized Then lGdx.Pause
End Sub
Sub LG_Create
    lGdx.CallSubUI("Show_Loading", Null)
 
    'Initializes the asset manager
    AM.Initialize("AM")
    'Adds a few assets to the loading queue of the asset manager
    AM.TiledMapLoader = AM.MAPLOADER_TMX
    AM.Load("maps/map_001.tmx", AM.TYPE_TiledMap)
    AM.Load("fonts/comic2.fnt", AM.TYPE_BitmapFont)
    AM.Load("audio/mus_main.ogg", AM.TYPE_Music)
    AM.Load("audio/ding.ogg", AM.TYPE_Sound)
    AM.Load("parts/explode_02.p", AM.TYPE_ParticleEffect)
    '  Setup the screen manager
    lGdx_ScrMgr.Initialize(lGdx)
    lGdx_Screen(0) = lGdx_ScrMgr.AddScreen("LGS0")
    lGdx_Screen(1) = lGdx_ScrMgr.AddScreen("LGS1")
    lGdx_ScrMgr.CurrentScreen = lGdx_Screen(0)
End Sub
Sub LG_Resize(Width As Int, Height As Int)
End Sub
Sub LG_Render
    'Loads the assets asynchronously
    If AM.Update Then
        lGdx.CallSubUI("Update_Loading", AM.Progress)
        Return
    Else
        lGdx.CallSubUI("Hide_Loading", Null)
    End If
End Sub
Sub LG_Pause
End Sub
Sub LG_Resume
End Sub
Sub LG_Dispose
    AM.dispose
End Sub
Sub AM_Error(FileName As String, Class As Object, Message As String)
    LogColor("- libGDX AssetManager ERROR !!! ---", Colors.Red)
    LogColor("    FileName = " & FileName, Colors.Red)
    LogColor("    Class = " & Class, Colors.Red)
    LogColor("    Message = " & Message, Colors.Red)
    LogColor("- libGDX AssetManager ERROR !!! ---", Colors.Red)
End Sub
Private Sub Show_Loading(dummy As Object)
    pgbLoading.Progress = 0
    panLoading.Visible = True
    DoEvents
End Sub
Private Sub Update_Loading(Progress As Float)
    pgbLoading.Progress = (Progress * 100)
    DoEvents
End Sub
Private Sub Hide_Loading(Dummy As Object)
    If panLoading.Visible = False Then
        Return
    End If
    pgbLoading.Progress = 100
    DoEvents
    panLoading.Visible = False
End Sub
#Region Screen 0
'-------------------------------------------------------------------------------------
' SCREEN 0 (first screen)
'-------------------------------------------------------------------------------------
Sub LGS0_Show
    Log("screen 0 show")
   
    'Initializes the Stage
    Stage(0).Initialize("ST_0")
    'Adds a capture listener to the stage to filter the input events
    Dim IL As lgScn2DInputListener
    IL.Initialize("ST_0")
    Stage(0).AddCaptureListener(IL)
    'Creates the main table
    Table(0).Initialize("Table0")
    Table(0).FillParent = True
    Stage(0).AddActor(Table(0))
'    Uncomment here to produce Null Pointer errors
   
'    foComicFont = AM.Get("fonts/comic2.fnt")
'    foComicFont.SetTextureFilter(foComicFont.FILTER_Linear, foComicFont.FILTER_Linear)
'    foComicFont.Scale(Density)
'   
    'Creates the score label
'    Dim lblStyle As lgScn2DLabelStyle
'    lblStyle.Initialize(foComicFont, foComicFont.Color.WHITE)
'    lblScore.Initialize("Score" & CRLF & "000000", lblStyle, "")
'    Table(0).AddActor(lblScore).AlignLeft
   
End Sub
Sub LGS0_Resize(Width As Int, Height As Int)
    Log("screen 0 resize")
    'Sets the stage viewport
    Stage(0).SetViewport(Width, Height, True)
End Sub
Sub LGS0_Render(Delta As Float)
    'Log("1 render " & Delta)
    'Clears the screen
    GL.glClearColor(1, 0 , 0, 1)
    GL.glClear(GL.GL10_COLOR_BUFFER_BIT)
    'Applies the actions to actors
    Stage(0).Act2(Delta)
   
    'Draws the actors
    Stage(0).Draw
End Sub
Sub LGS0_Pause
    Log("screen 0 pause")
End Sub
Sub LGS0_Resume
    Log("screen 0 resume")
End Sub
Sub LGS0_Hide
    Log("screen 0 hide")
    Stage(0).dispose
    'foComicFont.dispose
    Log("screen 0 disposed")
End Sub
Sub ST_0_TouchDown(Event As lgScn2DInputEvent, X As Float, Y As Float, Pointer As Int)
    '...
    Event.Handle
End Sub
Sub ST_0_TouchUp(Event As lgScn2DInputEvent, X As Float, Y As Float, Pointer As Int)
    '...
    lGdx_ScrMgr.CurrentScreen = lGdx_Screen(1)
    Event.handle
End Sub
#End Region
#Region Screen 1
'-------------------------------------------------------------------------------------
' SCREEN 1 (second screen)
'-------------------------------------------------------------------------------------
Sub LGS1_Show
    Log("screen 1 show")
   
    'Initializes the Stage
    Stage(1).Initialize("ST_1")
    'Adds a capture listener to the stage to filter the input events
    Dim IL As lgScn2DInputListener
    IL.Initialize("ST_1")
    Stage(1).AddCaptureListener(IL)
    'Creates the main table
    Table(1).Initialize("Table1")
    Table(1).FillParent = True
    Stage(1).AddActor(Table(1))
End Sub
Sub LGS1_Resize(Width As Int, Height As Int)
    Log("screen 1 resize")
    'Sets the stage viewport
    Stage(1).SetViewport(Width, Height, True)
End Sub
Sub LGS1_Render(Delta As Float)
    'Log("1 render " & Delta)
    'Clears the screen
    GL.glClearColor(0, 0 , 1, 1)
    GL.glClear(GL.GL10_COLOR_BUFFER_BIT)
    'Applies the actions to actors
    Stage(1).Act2(Delta)
   
    'Draws the actors
    Stage(1).Draw
End Sub
Sub LGS1_Pause
    Log("screen 1 pause")
End Sub
Sub LGS1_Resume
    Log("screen 1 resume")
End Sub
Sub LGS1_Hide
    Log("screen 1 hide")
    Stage(1).dispose
    Log("screen 1 disposed")
End Sub
Sub ST_1_TouchDown(Event As lgScn2DInputEvent, X As Float, Y As Float, Pointer As Int)
    '...
    Log("Screen 01 touch down event")
    flTouchDown = DateTime.Now   
    Event.Handle
End Sub
Sub ST_1_TouchUp(Event As lgScn2DInputEvent, X As Float, Y As Float, Pointer As Int)
    '...
    If (DateTime.Now - flTouchDown) < 2000 Then
        lGdx_ScrMgr.CurrentScreen = lGdx_Screen(0)
    Else
        Activity.Finish
    End If
    Event.handle
End Sub
#End Region