Sub Process_Globals
End Sub
Sub Globals
Dim lGdx As LibGDX
Dim GL As lgGL
Dim Camera, CameraFont As lgOrthographicCamera
Dim World As lgBox2DWorld
Dim Renderer As lgBox2DDebugRenderer
Dim LG_Batch As lgSpriteBatch
Dim Font As lgBitmapFont
End Sub
Sub Activity_Create(FirstTime As Boolean)
lGdx.Initialize("LG")
End Sub
Sub LG_Create
'Initializes the sprite batcher
LG_Batch.Initialize
'Font
Font.Initialize
Font.SetColorRGBA(1,0,0,1)
Font.Scale(Density*2)
'Debug renderer
Renderer.Initialize2(True, False, False, True, True, True)
'World
Dim vGravity As lgMathVector2
World.Initialize(vGravity.set(0, -10), True, "Box2D")
World.SetContinuousPhysics(True)
World.SetWarmStarting(True)
'I create objects (floor 2.8x0.5 meters)
'Floor
Dim fd As lgBox2DFixtureDef
Dim sd As lgBox2DPolygonShape
sd.setAsBox(1.4,.25)
fd.shape = sd
Dim bd As lgBox2DBodyDef
bd.position.set(1.5,.25)
World.createBody(bd).createFixture(fd)
sd.1dispose
'Box (2x2 meters)
Dim fd As lgBox2DFixtureDef
Dim sd As lgBox2DPolygonShape
sd.setAsBox(1,1)
fd.shape = sd
Dim bd As lgBox2DBodyDef
bd.position.set(1.5,4.5)
bd.type=World.BODYTYPE_Dynamic
World.createBody(bd).createFixture(fd)
sd.dispose
End Sub
Sub LG_Resize(Width As Int, Height As Int)
'In my example I create a 3x5 camera
Camera.Initialize2(3, 5)
Camera.Position.set(1.5,2.5,0)
'I create a second camera with actual size of the device. In this camera I draw the text.
'Set CameraFont
CameraFont.Initialize2(lGdx.Graphics.Width,lGdx.Graphics.Height)
CameraFont.Position.set(lGdx.Graphics.Width/2,lGdx.Graphics.Height/2,0)
End Sub
Sub LG_Render
'Clears the screen
GL.glClear(GL.GL10_COLOR_BUFFER_BIT)
'Updates the matrices of the cameras
Camera.Update
'Updates and draws the simulation
LG_Update
Renderer.render(World.InternalObject, Camera.Combined)
'Font
CameraFont.Update
LG_Batch.ProjectionMatrix = CameraFont.Combined
LG_Batch.begin
Font.Draw(LG_Batch,"B4A",lGdx.Graphics.Width*.25,lGdx.Graphics.Height*.75)
LG_Batch.end
End Sub
Sub LG_Update
World.Step(1/60, 8, 3)
End Sub
Sub LG_Dispose
'Disposes all resources
Renderer.dispose
World.dispose
End Sub