jita88 / box2d-editor

Automatically exported from code.google.com/p/box2d-editor
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
Hi Manuel,

i actually have the same problem. Can you please tell me how you fixed this or 
can you send me the fixed BodyEditor-loader.jar? I still get Errors if i try to 
compile.

Thanks a lot!

Stephan

Original comment by stebeme...@gmail.com on 25 Apr 2013 at 8:00

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This is my patched BodyEditorLoader.java file on pastie: 
http://pastie.org/7720857
You should be able to drop it in place of the old one.

Original comment by manuel....@gmail.com on 25 Apr 2013 at 9:07

GoogleCodeExporter commented 8 years ago
Thank you very much! Especially for your quick response :) 
It works!

Original comment by stebeme...@gmail.com on 26 Apr 2013 at 10:10

GoogleCodeExporter commented 8 years ago
Happy you got it working!

Original comment by manuel....@gmail.com on 26 Apr 2013 at 10:20

GoogleCodeExporter commented 8 years ago
Latest libgdx changed Json parsing again, this time for the better!
Please read this for more information about the changes: 
http://www.badlogicgames.com/wordpress/?p=2993

Here is my patched BodyEditorLoader.java: http://pastie.org/7747045

Original comment by manuel....@gmail.com on 1 May 2013 at 9:33

GoogleCodeExporter commented 8 years ago
Hi manuel,

i actually have the same problem too and also i dont know how to replace the 
old one because it seems i dont know how, please will you send me your .jar 
instead?

Original comment by montecil...@gmail.com on 13 Jul 2013 at 8:25

GoogleCodeExporter commented 8 years ago
montecil, you can just create the package aurelienribon.bodyeditor and put 
manuel's patch in. However, I attached a compiled .jar which you can use 
instead if you prefer.

Original comment by serverkorken@gmail.com on 18 Jul 2013 at 5:12

Attachments:

GoogleCodeExporter commented 8 years ago
@serverkorken thanks! its just what i need! 

Original comment by montecil...@gmail.com on 13 Aug 2013 at 8:33

GoogleCodeExporter commented 8 years ago
Thank you so much! :D
This Bug isn't fixed yet in the normal Download

Original comment by markus.k...@yahoo.de on 30 Oct 2014 at 6:49