Games [XUI2D] Example Pack

Not open for further replies.


Staff member
Licensed User
1. BitmapCreator v4.20 released and X2 framework updated. The drawing of anti-aliased rotated graphics is significantly faster now (on B4J and B4i). The performance improvement can be up to 10 times faster in some cases.

2. New example added that shows how to use tile map in a non-scrolling game.



Active Member
Licensed User
Dear Erel,

well I saw in all your examples that left and right from the pricture the background is always visible? May be a typo in the designer script:

When GameRatio replaced by ScreenRatio - this spaces are gone! (here modified setting)

Here Mario with GameRatio (original setting):
Mario GameRatio.PNG

and with ScreenRatio (modified setting):
Mario ScreenRatio.PNG

What you think? Is it locally at my phone or as one can see in your exapmle videos with spaces intendet?
Last edited:


Staff member
Licensed User
Updated "Ilan's first app" example. The balls are created with random colors instead of being loaded from an image file:


The relevant code is:
'returns the graphic name
Private Sub CreateCircleForBall (Shape As B2Shape) As String
   Dim ballsize As B2Vec2 = X2.GetShapeWidthAndHeight(Shape)
   'we could have used B4XCanvas here instead of BitmapCreator.
   Dim bc As BitmapCreator
   bc.Initialize(X2.MetersToBCPixels(ballsize.X), X2.MetersToBCPixels(ballsize.Y))
   'inner circle
   bc.DrawCircle(bc.TargetRect.CenterX, bc.TargetRect.CenterY, bc.mWidth / 2 - 2, Rnd(0xff000000, -1), True, 0)
   'outer circle
   bc.DrawCircle(bc.TargetRect.CenterX, bc.TargetRect.CenterY, bc.mWidth / 2, xui.Color_Black, False, 2)

   Dim sb As X2ScaledBitmap
   sb.Scale = 1
   sb.Bmp = bc.Bitmap
   'add to cache
   Dim gname As String = X2.GraphicCache.GetTempName
   'the balls are simple circles so there is no reason to "rotate" them. Setting AngleInterval to 360 disables rotation.
   X2.GraphicCache.PutGraphic2(gname, Array(sb), True, 360)
   Return gname
End Sub

Creating many temporary graphics can harm performance as they are not reused between different bodies. In this case it is not problematic as the circles are never rotated.


Staff member
Licensed User
I've made a relatively large update.

objecttypes.json was updated as well. Its version is: 0.98


There is a new property named 'nearest neighbor scaling'. This is an alternative resizing algorithm which in some cases produces better results. It is used in the angry birds example for the hook and the bricks.

Some changes were made in X2SpriteGraphicCache. There is a new PutGraphicBCs that accepts a list of BitmapCreators, instead of a list of X2ScaledBitmaps.


Staff member
Licensed User
The example pack was updated. Using the new b4x libraries feature, all the X2 modules (and the objecttypes.json file) are now packed as a single b4x library named X2.
It is available here:

1. You need to use B4A v8.80+ or B4J v7.0+ or B4i (TBD).

2. Download the X2 library and copy it to the additional libraries folder.

The source code of the X2 modules is available in the included X2 Source Code project.
Not open for further replies.