Games [XUI2D] Displaying a Tiled background


Active Member
Licensed User
Longtime 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
TileMap.Initialize(X2, File.DirAssets, "hello world.json", Null)


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.


    169.5 KB · Views: 217


B4X founder
Staff member
Licensed User
Longtime User
You need to do two things:
1. Call in Game.Tick:
TileMap.DrawScreen(Array("Tile Layer 1"), GS.DrawingTasks)

2. Call in Game.DrawingComplete:
Public Sub 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.