Skip to content

Latest libgdx's json loader changed behavior for Long/Floats #23

@GoogleCodeExporter

Description

@GoogleCodeExporter
Using the latest libgdx, the BodyEditorLoader will throw an exception as soon 
as it try to cast a Long to a Float since the current behavior changed.

The fix is quite easy: just perform an "instanceof" check before casting and 
choose the right type before performing the type conversion.

As an example, here is what i'm doing:

    rbModel.origin.x = (originElem.get("x") instanceof Float) ? (Float)originElem.get("x") : (Long)originElem.get("x");
    rbModel.origin.y = (originElem.get("y") instanceof Float) ? (Float)originElem.get("y") : (Long)originElem.get("y");

This has to be done for polygons and circles as well.

Original issue reported on code.google.com by manuel....@gmail.com on 21 Apr 2013 at 2:12


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions