Libgdx HTML5 Backend Update

I spent almost a week and a half on the HTML5 backend now and i’m happy to say that i could actually add more than i expected.

New Additions

  • Reflection. Yes, that’s a stupid idea with GWT, but it enables a few things. You can’t use it for your own apps at the moment. Not sure i’ll open up that can of worms. If you are interested in how it works, check out this bozo.
  • Json parsing with reflection. If you read into an ObjectMap things will just work. If you want to deserialize into your own POJOs i’ll have to add something so your POJOs are reflected.
  • The entire scene2d package, including the UI stuff. This was enabled by adding basic Reflection capabilities
  • All of Box2D works now, expect for GearJoint, WheelJoint and RopeJoint. The former two are currently broken in the JBox2D trunk, once those are fixed we have everything apart from RopeJoint.
  • Preferences
  • Fullscreen support
  • Tons of other stuff under the hood that won’t affect you
  • Binary file support, altough i recommend not using it, it’s slow by nature

You can try out most of our tests in HTML5 now. Some box2d tests might be slow due to ShapeRenderer. The box2d simulation itself runs blazingly fast 🙂


  • Replace gwt-voices with something else, e.g. a Sound Manager 2 wrapper. I didn’t dig into the gwt-voices sources to much, but for some reason it refuses to work at all in Safari and partially in Firefox. Done, custom wrapper around SoundManager 2, a fantastic API that works perfectly.
  • Fix the backspace button problem so UI textfields work. Done
  • Add a very simple HttpUtils class that allows one to send POST/GET requests to a server. Note that due to the “Same Origin Policy” you’ll be restricted to send requests to the domain your app/game is hosted on.
  • Go through the list of FIXMEs in the source. Done, anything that’s marked as FIXME is either undoable for now, or non-critical.

I’ll most likely not support local files for the time being. Preferences should be sufficient for most games for now.

What Won’t Work

Tilemaps, Audio recorder/device, that’s about it. If i can find a nice Gzip decoder for GWT we can add Tilemaps in as well. Other than that we’ll be pretty much feature complete.

Simple Tutorial

I didn’t have time to write a tutorial on how to port your game yet. Here’s a nice tutorial by Molded Bits on how to get started with the new backend. The markers for files in the assets.txt file are: i -> image, t -> text file, b -> binary file. For now i won’t pack the backend jar with the nightlies as i want things to mature a tiny bit. I’ll follow up with something more in depth that will also show you how you can debug the emitted Javascript easily if necessary.


Here are a few recent ports.

Pax Britannica by Stefan Wagner.

Mathematiles by Nex

Vector Pinball (see libgdx trunk/demos/)

Gdx invaders (see libgdx trunk/demos/)

10 thoughts on “Libgdx HTML5 Backend Update

  1. Maybe it will help. I’m getting such errors during compilation:

    Compiling module magory.htmlsolitaires.HtmlSolitaires
    Validating newly compiled units
    Ignored 2 units with compilation errors in first pass.
    Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
    [ERROR] An internal compiler exception occurred Failed to get JNode
    at org.eclipse.jdt.internal.compiler.ast.FieldDeclaration.traverse(
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(
    [ERROR] : public class com.badlogic.gdx.scenes.scene2d.ui.Label
    extends com.badlogic.gdx.scenes.scene2d.ui.Widget
    /* fields */
    private final [unresolved] bounds
    private [unresolved] Unresolved type cache
    private [unresolved] int labelAlign
    private [unresolved] float lastPrefHeight
    private [unresolved] lineAlign
    private [unresolved] float prefHeight
    private [unresolved] float prefWidth
    private [unresolved] Unresolved type com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle style
    private [unresolved] java.lang.CharSequence text
    private [unresolved] boolean wrap
    /* methods */
    public void (com.badlogic.gdx.scenes.scene2d.ui.Skin)
    public void (java.lang.CharSequence, com.badlogic.gdx.scenes.scene2d.ui.Skin)
    public void (java.lang.CharSequence, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle)
    public void (java.lang.CharSequence, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle, java.lang.String)
    public void (java.lang.CharSequence, java.lang.String,, com.badlogic.gdx.scenes.scene2d.ui.Skin)
    public void (java.lang.CharSequence, java.lang.String, java.lang.String, com.badlogic.gdx.scenes.scene2d.ui.Skin)
    [unresolved] private void computeBounds()
    [unresolved] public void draw(, float)
    [unresolved] public getColor()
    [unresolved] public float getPrefHeight()
    [unresolved] public float getPrefWidth()
    [unresolved] public Unresolved type com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle getStyle()
    [unresolved] public java.lang.CharSequence getText()
    [unresolved] public getTextBounds()
    [unresolved] public void layout()
    public void setAlignment(int)
    [unresolved] public void setAlignment(int, int)
    [unresolved] public void setColor(float)
    [unresolved] public void setColor(
    [unresolved] public void setColor(float, float, float, float)
    [unresolved] public void setStyle(Unresolved type com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle)
    public void setText(java.lang.CharSequence)
    [unresolved] public void setWrap(boolean)
    /* members */
    public static class com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle
    extends java.lang.Object
    enclosing type : com.badlogic.gdx.scenes.scene2d.ui.Label
    /* fields */
    public [unresolved] font
    public [unresolved] fontColor
    /* methods */
    [unresolved] public void ()
    public void (,

    [ERROR] at Label congratulations;

  2. That’s amazing!!
    I’m planning to port something on this new backend, but I have a project with extensive use of RopeJoints, so I was wondering…by any chance, will the problem about RopeJoint support be solvable eventually or it is not feasible at all?

  3. Amazing

    Libgdx just gets better and better every day. Good job on the fast development! Now we just need iOS support and it will be the ultimate game dev lib for any platform.

Leave a Reply

Your email address will not be published.