Android Question LibGdx: First steps...

KMatle

Expert
Licensed User
Longtime User
Hi guys,

today I tried one of the examples to render a isometric map. I painted an own using "tiled" and replaced the one in the example with the new one. Problem is that the map will be rendered as a complete black surface. After playing arround I don't get any further. Any quick idea? Must be something stupid.



B4X:
Sub LG_Create
    'Loads the isometric map (TMX format)
    Dim TMXLoader As lgMapTmxMapLoader
    TiledMap = TMXLoader.Initialize2("maps/tmx/isometric/Map.tmx")

    'Logs some information about this map
    Log("--------")
    Log("Map properties:")
    Dim lstProperties As List = TiledMap.Properties.GetAllKeys
    For i = 0 To lstProperties.Size - 1
        Dim obj As Object = TiledMap.Properties.Get(lstProperties.Get(i))
        Log("- " & lstProperties.Get(i) & "=" & obj)
    Next
    Log("- nb. of layers=" & TiledMap.Layers.Count)
    Dim lstTilesets As List = TiledMap.TileSets.GetAllTilesets
    Log("- nb. of tilesets=" & lstTilesets.Size)
    Log("--------")
    Log("Layer properties:")
    Dim FirstLayer As lgMapTiledMapLayer = TiledMap.Layers.Get(0)
    Log("- name=" & FirstLayer.Name)
    Log("- nb. of objects=" & FirstLayer.Objects.Count)
    Log("--------")
    Log("Tileset properties:")
    Dim FirstTileset As lgMapTiledMapSet = lstTilesets.Get(0)
    Log("- name=" & FirstTileset.Name)
    lstProperties = FirstTileset.Properties.GetAllKeys
    For i = 0 To lstProperties.Size - 1
        Dim obj As Object = FirstTileset.Properties.Get(lstProperties.Get(i))
        Log("- " & lstProperties.Get(i) & "=" & obj)
    Next
    Log("- size=" & FirstTileset.Size)
    Log("--------")

    'Initializes the renderer
    Renderer.Initialize3(TiledMap, 1/32)
End Sub

Sub LG_Resize(Width As Int, Height As Int)
    'Sets the camera viewport
    Camera.Initialize
    Camera.SetToOrtho2(False, (Width / Height) * 15, 15)
    Camera.Position.Set(13, 0, 0)
End Sub

Sub LG_Render
    'Clears the screen
    GL.glClearColor(0.55, 0.55, 0.55, 1)
    GL.glClear(GL.GL10_COLOR_BUFFER_BIT)

    'Updates the matrices of the camera
    Camera.Update
    Renderer.SetCameraView(Camera)

    'Draws the tiled map
    Renderer.Render
End Sub
 

notedop

Member
Licensed User
Longtime User
1/32 should be the ratio between screenwidth or height and mapwidth or height.
Is 1/32 the correct ratio?
B4X:
Renderer.Initialize3(TiledMap, 1/32)

Also have a look at your camera position, try to center it first to viewport width without setting the position.

"SetToOrtho2 (yDown AsBoolean, ViewportWidth AsFloat, ViewportHeight AsFloat)Sets this camera to an orthographic projection, centered at (viewportWidth/2, viewportHeight/2), with the y-axis pointing up or down"

If that works, you can play around with the settings later on.
 
Last edited:
Upvote 0
Top