Games [XUI2D] Example Pack

Discussion in 'Game Development' started by Erel, Aug 23, 2018.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    Peter Simpson likes this.
  2. Gunther

    Gunther 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)
    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: Sep 27, 2018
    ocalle likes this.
  3. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for any question you have. Also make sure to post code as text instead of a screenshot.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Examples were updated based on BitmapCreator v4.30. BitmapCreator now supports several drawing methods:
    DrawLine, DrawCircle and DrawRect.
     
    Peter Simpson likes this.
  5. Erel

    Erel Administrator 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:

    [​IMG]

    The relevant code is:
    Code:
    '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 - 2Rnd(0xff000000, -1), True0)
       
    'outer circle
       bc.DrawCircle(bc.TargetRect.CenterX, bc.TargetRect.CenterY, bc.mWidth / 2, xui.Color_Black, False2)

       
    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), True360)
       
    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.
     
    inakigarm, Toky Olivier and ilan like this.
  6. Erel

    Erel Administrator Staff Member Licensed User

    Added parallax background to 'clumsy bird' example:

     
    Toky Olivier, inakigarm and Gunther like this.
  7. Erel

    Erel Administrator Staff Member Licensed User

  8. Erel

    Erel Administrator Staff Member Licensed User

  9. Erel

    Erel Administrator Staff Member Licensed User

  10. Erel

    Erel Administrator Staff Member Licensed User

    I've made a relatively large update.

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

    [​IMG]

    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.
     
    Johan Hormaza likes this.
  11. Erel

    Erel Administrator Staff Member Licensed User

    New video tutorial added to the first post. Explains the steps required to run the examples and configure the tools.
     
    ellpopeb4a and inakigarm like this.
  12. Erel

    Erel Administrator Staff Member Licensed User

  13. Erel

    Erel Administrator 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: 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.
     
    inakigarm likes this.
  14. Erel

    Erel Administrator Staff Member Licensed User

    Mouse following path example updated. An "enemy" mouse was added that follows the first mouse.

    The implementation is very simple and not 100% physical. It can be improved by using a motor joint (like done with the first mouse).
     
    inakigarm, Toky Olivier and ilan like this.
  15. Erel

    Erel Administrator Staff Member Licensed User

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