B4A Library libGDX - Game Engine



One of the best game engines for Android is now available to B4A users. Unleash your creativity!

You can read a description of this library in this guide.

Download for B4A v10.60 and older (4 MB)
Download for B4A v10.70 and newer (4 MB)

Starting from version 1.13, the library is compiled with Java 8, and thus requires a recent version of B4A and Java 8+.
To install the library, copy the .jar file and the .xml file in your libraries folder.

This library is not compatible with the Debug mode. Ensure that you always compile in Release mode.

Download also the examples and templates.

You can reduce the weight of the library if you want to keep your APK file as small as possible. Read this post to learn how to create your Lite version.

Tutorials:
How to make games
Introduction to the libGDX library
PacDroid: from scratch to fun
Shaders

Take also a look at the Cloney Bird tutorial by andymc.

Plugins:
Box2DLights
SpecialFX

Versions:
 
Last edited by a moderator:

sterlingy

Active Member
Licensed User
Longtime User
Informatix, I believe it is working now. I forgot to turn off debug mode on the last compile

Thank you SOOOOOOOOOO much.

-SterlingY
 

sterlingy

Active Member
Licensed User
Longtime User
Informatix. Here's something to chew on:

As the camera moves up the map, eventually the map end, and the Pacdroid moves into blackness (no background map.) Maps are always located with the lower left corner at (0,0). What I'd like to do is place another map and the end of the first one, and repeat this over and over, kind of like and endless runner type game.

Do you have any thoughts on how to achieve this?

Cheers,

SterlingY
 

Informatix

Expert
Licensed User
Longtime User
I don't know what's the best solution in this case. Usually, the platform games with a side scrolling have various landscapes so there's no need for repeated tiles. And the never-ending-scrolling techniques are for textures, not tiles. If you find something that works fine, let us know.
 

sterlingy

Active Member
Licensed User
Longtime User
I did find this: https://github.com/MobiDevelop/libg...adlogic/gdx/tests/examples/RunnerExample.java

I was in the process of porting it to B4A, but I ran into some hurdles, as usual. For instance, it extends other classes, including one called "GdxTest" which I have know idea about.

Then there's this stuff, which I could find any reference to in your port of libGDX:
B4X:
import com.badlogic.gdx.maps.tiled.TiledMapTile;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell;
import com.badlogic.gdx.maps.tiled.TiledMapTileSet;
import com.badlogic.gdx.maps.tiled.TiledMapTileSets;

The coder of the above link wrote this to me on the libGDX forum:


Maybe your brilliant brain can figure it out.

Cheers,

SterlingY
 

Informatix

Expert
Licensed User
Longtime User

That looks good.

GdxTest is an abstract class with no code, so you don't need it.

com.badlogic.gdx.maps.tiled.TiledMapTile -> it's an interface, not a class (example of class using this interface: lgMapStaticTiledMapTile)
com.badlogic.gdx.maps.tiled.TiledMapTileLayer -> lgMapTiledMapLayer
com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell -> lgMapTiledMapLayerCell
com.badlogic.gdx.maps.tiled.TiledMapTileSet -> lgMapTiledMapSet
com.badlogic.gdx.maps.tiled.TiledMapTileSets -> lgMapTiledMapSets

Maybe your brilliant brain can figure it out.

My skull contains more mud than brain actually.
 

sterlingy

Active Member
Licensed User
Longtime User
Informatix, I've been trying to port the RunnerExample.java. Mostly it's not to difficult, but a few things I'm having trouble with:

I can't find OrthoCamController I assumed it would have been lgOrthoCamController

TextureRegion[][] splitTiles = TextureRegion.split(tiles, 32, 32)
I don't know what to do following the "=" as TextureRegion is not a variable

map1.getTileSets().addTileSet(tileset)
The closest I could get is : map1.TileSets.getTileSet. (and then there is no option for addTileSet)

super(map)
Not sure what super is, but it's probably not a libGDX thing

map.getLayers()
Am I assuming correctly that this translate to map.Layers.GetAllLayers?

I hope to have this working over the weekend. I'll share it with everyone, as it might be of some use. You could probably do this in 30 minutes, but even though I struggle, it helps me learn.

Cheers,

Sterling
 

Informatix

Expert
Licensed User
Longtime User
I can't find OrthoCamController I assumed it would have been lgOrthoCamController

If I remember correctly, it's some code to move the camera in the test apps. It's not a part of the lib and you can do the same thing with B4A (e.g. with the gesture detector).

TextureRegion[][] splitTiles = TextureRegion.split(tiles, 32, 32)
I don't know what to do following the "=" as TextureRegion is not a variable

Look at my Animation demo and my Map_Hexagonal demo. I show two ways to get arrays from a split.

map1.getTileSets().addTileSet(tileset)
The closest I could get is : map1.TileSets.getTileSet. (and then there is no option for addTileSet)

lgMapTiledMapSets (note the final s)

super(map)
Not sure what super is, but it's probably not a libGDX thing

Yes, forget. It calls the constructor of the ancestor of the class (you don't need to bother with that in general with B4A).

map.getLayers()
Am I assuming correctly that this translate to map.Layers.GetAllLayers?

No, to map.Layers. When a library is wrapped, usually the get and set are removed and the two functions become a single property in B4A.

I hope to have this working over the weekend. I'll share it with everyone, as it might be of some use.

Great.

Sunday, I take the plane to La Réunion island for the Christmas holidays so I won't be able to help before 2014.
 

sterlingy

Active Member
Licensed User
Longtime User
Thanks Informatix. Everything above is a great help. If we don't connect before, have a wonderful Christmas and New Years

Cheers,

Sterling
 

Beja

Expert
Licensed User
Longtime User
Thanks Informatix for the great lib and examples..

I go this error message in ALL of the examples:
 

sterlingy

Active Member
Licensed User
Longtime User
Informatix,

I finished porting the runnerExample.Java code. I can't run it yet because there are a few things I still can't find:

For starters, this is suppose to be an extension BatchSpriteMapRenderer, So I think I've not set up my globals and initialized properly


Again, I hope you have or have had a great vacation. I'm in sunny California now, but will be in sub-zero temps in New England for the holidays.

-Sterlingy

P.S. I don't know why the code didn't retain it's indent formatting
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
Thanks Informatix for the great lib and examples..

I go this error message in ALL of the examples:
In the Basic4Android IDE, go to “Tools/Configure Paths”. Be sure the android.jar is set to version 11 or higher (this setting is important to compile successfully but has no influence on the Android version required by your application, which is set in the manifest by minSdkVersion, so you can select the latest Jar present in your Android SDK folder).

"hardwareAccelerated" is not in all examples. Only a few. It is useless. You can remove the line in the manifest.
 

Informatix

Expert
Licensed User
Longtime User
Now that I looked closely to the code of the example, I realize that it is not easy to port to B4A (you have to extend another class, which is impossible, and not extending it complicates a lot your work). I planned for the beginning of 2014 to update my code to the version 0.9.9 of libGDX. I will provide you a solution to endlessly scroll a map at this moment. I hope you can wait a few weeks.
 

sterlingy

Active Member
Licensed User
Longtime User
Informatix,

I will provide you a solution to endlessly scroll a map at this moment. I hope you can wait a few weeks.

You rock. Yes, I can wait. I can work on other aspects of the mechanics, and if I run out of things to do, or just become stumped, I'll work on graphic design, plus I'll be spending a lot of time with my family anyway.

If you are wondering about functionality, It would be good to be able to load multiple maps so that one can move from one onto another, like moving from the city to the country, to the desert, then back to the city, and so forth, as opposed to one map that just repeats itself, of course, that could be an option as well.

Also, despite hours working on this, all was not in vain. I learned a lot, especially with your help.

Have a blast, and rest up while you are away, if it is possible to both!

-Sterlingy
 

Beja

Expert
Licensed User
Longtime User
"hardwareAccelerated" is not in all examples. Only a few.

That was a big mistake of mine, and was against my responsible of being accurate. Neutrality is
very difficult to maintain. After trying 2 examples, then I took other two randomly and it happened
they were both with "hardwareAccelerated, so I wrongly concluded it is all of the examples.

Thank you very much for the note and the help.
 

Beja

Expert
Licensed User
Longtime User
Informatix,

Sorry but I utterly failed to add views to the activity by creating a .bal file in designer. no errors but the
app ran normally with no button shown on the screen.. Can these examples run inside a panel?
Thanks in advance
 

alhowiriny

Member
Licensed User
Longtime User
I've being away from this forum for months.. its good to see high quality library like this one. Thank you Informatix.
 

Informatix

Expert
Licensed User
Longtime User
Informatix,

Sorry but I utterly failed to add views to the activity by creating a .bal file in designer. no errors but the
app ran normally with no button shown on the screen.. Can these examples run inside a panel?
Thanks in advance

What you're trying to do is not really clear to me. You can place a libGDX view inside a panel, of course, but you cannot add this view in your designer. It has been done programmatically.
 

sterlingy

Active Member
Licensed User
Longtime User
Informatix,

I hope you had a great vacation!

You'd be stunned by the progress I've made with your lib. Of course, I still struggle, but I think I'm days away from an alpha release of my app. Right now, I am stumbling over one issue.

I used the application Tiled to create a map and some polyline objects. I want to read the polylines and use their vertices to create a BOX2D edge, but I can't figure out how to access this information from the tiled map object. I can see the object layer, but not sure how to get its vertices.

Thoughts?

-S
 

Informatix

Expert
Licensed User
Longtime User
I hope you had a great vacation!

Yes, I left La Reunion a few days before a cyclone strikes it. I just had news from my family on the island and they are out of danger now.

You'd be stunned by the progress I've made with your lib. Of course, I still struggle, but I think I'm days away from an alpha release of my app.

Great news! I'm working too with libGDX currently.


To be honest, I didn't test at all the lgMapPolylineMapObject class so I'm afraid that I'm of no help. I suppose that you get a polyline with one of the functions of this class and you can get its vertices with the getVertices function of the lgMathPolyline class.

I wish you (and everybody) a happy new year !
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…