Games [XUI2D] X2 v2.0 - 2021


B4X founder
Staff member
Licensed User
Longtime User

X2 is an open source, cross platform 2d game engine based on box2d physics engine and BitmapCreator as the rendering engine.
X2 itself is a b4xlib library.

The first versions of X2 lead the way to cross platform B4X projects. The new update goes the other way, and makes X2 work with B4XPages. This simplifies several things.
There is also a new class named X2Multitouch which provides a cross platform method to handle touches, multitouches and keys (B4J).

X2 works best with Tiled map editor:
Due to a compatibility with Tiled 1.9.0, please use this version for now:
When you first start with Tiled, you need to import the x2 custom properties. This is done with:
View - Objects Types Editor - File - Import and find objecttypes.json: X2\X2 Source Folder\Shared Files\objecttypes.json

If you are not seeing the custom properties when selecting an object then it is misconfigured:

X2 source code and examples are available on github:
Download link:
X2.b4xlib: Source Folder/X2.b4xlib

The first effort was to update the almost 20 examples to the new version.
Some of the examples are a bit complex and are more of a "proof of concept" projects.

1. Start with B4J
2. Start with these examples and more or less in this order (the examples threads were not yet updated):

- HelloWorld
- GameTemplate - same as File - New - X2 Game.
- Joints -
- Newton Cradle -
- Touchy -
- Ilan's First App -
- Tank Attack -
- Collisions -
- LargeBackground -
- ParallaxBackground -
- Breakout -
- Space Shooter -
- Monster Truck -
- Tetris - no physics game -
- TilesMap -
- Mouse Following Path -
- Clumsy Bird:
- Space Shooter -
- Angry Birds:
- Mario -
- Space Invaders -
- MultiplePages - A simple example where the template game is hosted in a different B4XPage.

Proof of concept projects:
- Walking Character - includes all kind of random features.
- Lines -
- Floating bodies:

- The files from the Shared Files folder are copied to the platform specific folder during compilation. Don't update the files in the Files folder as they will be overwritten (except of files unique to the current platform).

Updated X2 Game.b4xtemplate is attached. It includes the manifest line from post #10.


  • X2 Game.b4xtemplate
    91.2 KB · Views: 736
Last edited:


Licensed User
Longtime User
That's awesome erel. i believe that xui2d has a lot of potentials it just needs some published games in the store to prove it is a good framework and this will make it more interesting for people. i am planning to make one in the near future.

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
After updating; I got this error when opening B4J Space Shooter example:
Unknown type: b4xmainpage
Are you missing a library reference?
and the compiler error:
Error description: Unknown type: b4xmainpage
Are you missing a library reference?
Error occurred on line: 73 (B4XPages)
Public Sub MainPage As B4XMainPage
What I missed?


I am using B4A, and I see that the module Game.bas is for B4J.
Can you help please ?
Thank you in advance.