Games [XUI2D] Displaying a Tiled background

Discussion in 'Game Development' started by ac9ts, Sep 20, 2018.

  1. ac9ts

    ac9ts Active Member Licensed User

    When I start learning new concepts, I like to take examples and modify them to see how things work. I took HelloWorld_TileMap as a starting point. I wanted to see how to add a tiled background to it. I modified the hello world.json with a simple tile set. It all looks fine when loading it back into Tiled.

    In the Game class, I changed
    Code:
    TileMap.Initialize(X2, File.DirAssets, "hello world.json"Null)
    to

    Code:
    TileMap.Initialize(X2, File.DirAssets, "hello world.json", ivGround)
    The background is white (the gradient background sub was commented out). I'm not sure if it's the json file or my code. There are no errors displayed in the logs. I must be doing something simple but I can't seem to find it. Code is attached.
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    You need to do two things:
    1. Call in Game.Tick:
    Code:
    TileMap.DrawScreen(Array("Tile Layer 1"), GS.DrawingTasks)
    2. Call in Game.DrawingComplete:
    Code:
    Public Sub DrawingComplete
       TileMap.DrawingComplete
    End Sub
    Examples with tile map background: mario, monster truck and Tiles Map.

    I recommend you to start the game development with B4J. The test cycle is faster. You can later add B4A and B4i projects that reference the same modules.
     
    ac9ts likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice