libGDX 1.6.1 released – Build System Change!

libGDX 1.6.1

This release contains a major change to the build system. I had to change the way the iOS project handles native libraries. Up until today, the ios/build.gradle file had a two tasks, copyNatives, and updateRoboVMXML. When you import your project into an IDE or build it via the CLI, these tasks will walk through all dependencies, extract the static libraries and rewrite your robovm.xml file. That’s not really nice.

This release fixes this long standing issue. iOS native libraries, e.g. for gdx code, freetype, bullet or box2d, are now packaged using RoboVMs Jar layout for native libs. The static libraries are stored inside a jar, in the directory META-INF/robovm/ios/libs. Additionally, a small robovm.xml file is stored in META-INF/robovm/ios/robovm.xml. This file specifies the native libraries in the libs directory that RoboVM should link.

If you update an existing project to libGDX 1.6.1, you need to make a few changes to the build.gradle and ios/build.gradle files of your project!

In the root build.gradle file, you will see something like this for the iOS project:

project(":ios") {
    apply plugin: 'java'
    apply plugin: 'robovm'

    configurations { natives }

    dependencies {
        compile "org.robovm:robovm-rt:${roboVMVersion}"
        compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
    }
}

You need to change the natives config name to compile, just like what we use for the normal Java dependencies.

In the ios/build.gradle file, can remove the copyNatives and updateRoboVMXML tasks and any other line that references those tasks. You should end up with something like this (modulo your main class name!):

sourceSets.main.java.srcDirs = [ "src/" ]

sourceCompatibility = '1.7'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

ext {
	mainClassName = "com.mygdx.game.IOSLauncher"
}

launchIPhoneSimulator.dependsOn build
launchIPadSimulator.dependsOn build
launchIOSDevice.dependsOn build
createIPA.dependsOn build


eclipse.project {
    name = appName + "-ios"
    natures 'org.robovm.eclipse.RoboVMNature'
}

After this changes, simply set the gdxVersion in your root build.gradle to “1.6.1” and you are done.

Here are the full CHANGES for this release:

[1.6.1]
- Added optional hostname argument to Net.newServerSocket method to allow specific ip bindings for server applications made with gdx.
- Changed the way iOS native libs are handled. Removed updateRoboVMXML and copyNatives task from ios/build.gradle. Instead natives are now packaged in jars, within the META-INF/robovm/ios folder. Additionally, a robovm.xml file is stored there that gets merged with the project's robovm.xml file by RoboVM.

ROBOPODS

In other news, if you are interested in libGDX plus iOS you should cast your vote for RoboPods. RoboPods are bindings to 3rd party libraries like Admob, Google Play Game Services and so on that we at RoboVM will officially support going forward. See this blog post, including the poll.

Happy Coding!

libGDX 1.6.0 released

libGDX 1.6.0

Time for a new release, lock-stepping with RoboVM 😀

The CHANGELOG:

[1.6.0]
- API Change: GlyphLayout xAdvances now have an additional entry at the beginning. This was required to implement tighter text bounds. #3034
- API Change: Label#getTextBounds changed to getGlyphLayout. This exposes all the runs, not just the width and height.
- In the 2D ParticleEditor, all chart points can be dragged at once by holding ctrl. They can be dragged proportionally by holding ctrl-shift.
- Added Merge button to the 2D ParticleEditor, for merging a loaded particle effect file with the currently open particle effect.
- Added ability to retrieve method annotations to reflection api
- Added PixmapPacker.updateTextureRegions() method.
- Added ability to pack "anonymous" pixmaps into PixmapPacker, which will appear in the generated texture but not a generated or updated TextureAtlas
- Added PixmapPacker.packDirectToTexture() methods.
- API Change: PixmapPacker.generateTextureAtlas(...) now returns an atlas which can be updated with subsequent calls to PixmapPacker.updateTextureAtlas(...)
- API Change: FreeTypeFontGenerator.generateFont(...) now works with a user-provided PixmapPacker.
- Added DirectionalLightsAttribute, PointLightsAttribute and SpotLightsAttribute, removed Environment#directionalLights/pointLights/spotLights, added Environment#remove, lights are now just like any other attribute. See also https://github.com/libgdx/libgdx/wiki/Material-and-environment#lights
- API Change: BitmapFont metrics now respect padding. #3074
- Update bullet wrapper to v2.83
- Added AnimatedTiledMapTile.getFrameTiles() method

Note: Make sure to update your RoboVM Eclipse plugin to 1.2.0! There’s now also a RoboVM IntelliJ IDEA plugin!

Let us know if you run into any issues. See this wiki article on how to update your libGDX project to the latest version. The current libGDX version is “1.6.0”, the current nightly version is “1.6.1-SNAPSHOT”, OR you can just check our versions page which details all the versions of dependencies as well.

If you ever thought “I love all this free libGDX stuff, how can i contribute back?” then you got multiple options:

  1. Take part in the libGDX community, spread your knowledge (like /u/serapth) and maybe even send a pull request.
  2. If you have any interest in cross-platform mobile dev for iOS, Android and soon Windows 10 with Java or an alternative JVM language, check out RoboVM. Maybe even consider buying a license while they are 50% off (Solo is $99). Would also be great if you told your (Android dev) friends about it.

Did i mention that RoboVM is still free to use as before? No strings attached. A license just gives you new features like Interface Builder support, not usually relevant to game devs. You don’t have to pay us a dime to use it with libGDX (or a normal iOS app). So there’s that.

That 50% discount offer ends tomorrow. Help put some food on my table :)

One more thing before i leave: if you like libGDX but always found the lack of a code-centric WYSIWYG editor disturbing, check out [Overlap2D](http://overlap2d.com/). It’s fully OSS now, so jump in, contribute, make it awesome, NAO!

Happy Coding.

Font metrics changes

For bitmap fonts, padding can be added when the bitmap font is created to give more space around the glyphs for effects like a glow or drop shadow. BitmapFont has so far ignored padding, as reported in #3074. This means the font metrics change depending on the padding used, which makes it difficult to draw text where you want it. This PR has now been fixed, so the metrics are the same no matter how much padding is used around the glyphs.

Font metrics

Unfortunately this means that if you had been using a font that used padding, all of your carefully placed text may change size or position. You can go and fix this up everywhere, but for existing apps it is likely easier to just use this code to go back to the old behavior:

/** Adjusts the font data metrics to not take padding into account. */
static private void includePaddingInMetrics (BitmapFontData fontData) {
	float padY = fontData.padTop + fontData.padBottom;
	fontData.xHeight += padY;
	fontData.capHeight += padY;
	fontData.ascent -= padY;
	fontData.descent -= fontData.padBottom;
	fontData.padTop = 0;
	fontData.padLeft = 0;
	fontData.padBottom = 0;
	fontData.padRight = 0;
}