Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9216379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:24:19+00:00 2026-06-18T02:24:19+00:00

I have Tiled maps working in libgdx, now I’m trying to do collision with

  • 0

I have Tiled maps working in libgdx, now I’m trying to do collision with these maps. I figured it’d be really useful just to draw polygons in Tiled and use them for collisions in libgdx. I’d actually prefer it this way rather than doing a per tile collision since it’ll give me collision flexibility which the game requires.

I’ve successfully parsed each object’s xml and grabbed the polygon points. I’ve been able to make a box2d PolygonShape with these and it shows up in game! But it’s mirrored upside down…

I figured tiled must be on a different coordinate system than libgdx so I just created a function that finds the max y point and subtracts the rest of the y points from it in correct y flipping fashion. But now I’m getting this error:

java: /var/lib/hudson/jobs/libgdx-git/workspace/gdx/jni/Box2D/Collision/Shapes/b2PolygonShape.cpp:115: b2Vec2 ComputeCentroid(const b2Vec2*, int32): Assertion `area > 1.19209289550781250000e-7F' failed.

It looks like an error from libgdx’s native side. Is there anyone that can help me figure this out?

Here’s the relevant section from my tmx file.

<objectgroup height="20" name="Object Layer 1" width="20">
 <object x="100" y="320">
   <polygon points="0,0 244,1 300,50 300,95 -12,88 -29,19"/>
 </object>
 <object height="104" width="116" x="437" y="175"/>
</objectgroup>

Here’s the bit of code, it’s in Scala, that flips the polygon. It takes a Border object that has a polygon field which is just an array of Vector2s. The _type field is a symbol, it looks like it messes with stackoverflow’s syntax highlighting.

def flipPolygonY(border: Border){
    if(border._type == 'polygon){
        //find the highest y point
        var max = border.polygon(0).y
        for(vect <- border.polygon){
            max = max.max(vect.y)
        }
        //flip it, take max - y
        for(vect <- border.polygon){
            vect.set(vect.x, max - vect.y)
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:24:20+00:00Added an answer on June 18, 2026 at 2:24 am

    Okay I figured this out, doing some searching I read that Polygons must be defined in clockwise order. So on a hunch I reversed the order of my array or Vector2’s. It works. So if anyone else wants to use the polygons from Tiled in libgdx, flip them on the Y-axis and reverse the order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working in Google Maps and have three+ tile overlays to create. An
Essentially, what I'm trying to do is to load/draw a map from a Tiled
I have custom radar tiles that I am trying to overlay over Google Maps
I'm working with the Google Maps v3 API, and I have a custom overlay
I have a few maps (tilemaps made with Tiled QT) and I would like
I really need some help with the OSMdroid library. It is useful to have
I have a tiled background graphic with a header and footer part. Something like
I have a menu with tiled images w/text under them. See Fiddle: http://jsfiddle.net/techydude/GF8tS/ Is
I have an NSCollectionView that contains a collection of CustomViews . Initially it tiled
For a linearLayout, I want to have a gradient along with a tiled (repeated)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.