Games [XUI2D] Example Pack

Status
Not open for further replies.

Erel

B4X founder
Staff member
Licensed User
Longtime 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.
https://www.b4x.com/android/forum/threads/b4x-xui2d-box2d-game-engine.95208/#post-601674

2. New example added that shows how to use tile map in a non-scrolling game.
https://www.b4x.com/android/forum/t...ap-example-hello-world-with-background.97657/

SS-2018-09-27_17.09.08.png
 

Gunther

Active Member
Licensed User
Longtime 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)
GmeScreenRatio.PNG


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:

Erel

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

SS-2018-10-11_15.54.16.png


The relevant code is:
B4X:
'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.
 

Erel

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

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

SS-2018-11-07_17.19.56.png


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.
 

Erel

B4X founder
Staff member
Licensed User
Longtime 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: https://www.b4x.com/android/forum/threads/b4x-x2-xui2d-box2d-game-engine.95208/#post-601674

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.
 
Status
Not open for further replies.
Top