Collision and Object Handling


(Jonas Pongratz) #1

Hey there :slight_smile:
First, I have to thank you for your work on libtiled-java! It saved my day :smiley:
I’m a ComputerScience student from Germany (4th semester). We have a module this year, where we have to work in teams of 8 to build a running game in 4 months. Everyone has the same goals and there are Releases each month. The language is Java.

We started with JavaFX for our UI in the first Month (Chat, PlayerLobby, GameBrowser etc.).

The second months goal was to implement and show a map. The tmx-file and the tilesets have been given to us at the start. And we can use every engine or lib we want to achieve the goal.

I searched the web and came across your git and libtiled. I build it and now we have the libtiled-Java 1.0 Snapshot implemented in our Gradle Project.
The Map is shown at the JavaFX scene with a JScrollPane inside a SwingNode. Everything works fine except these things:

I can get the layers from the map easily. But they are all “MapLayers”. In the tmx file we have ObjectGroups for InGameObjects and a collision ObjectGroup too. But they are all “just” layers in the map.

QUESTIONS:

  • How can I get the gameObjects and the Coordinates of them with just the Map Layers. Is there a possibility for something like map.getLayer(0).getObjects…? Or how can I access the ObjectGroup info inside this layer?
  • How can I “interact” with the Collision Layer for something like "Does objA cross the collision boundaries?
    We have the polygon points in the tmx-file, but i couldn’t find the connection between a MapLayer and this information :confused:

Maybe these questions are too trivial, but I can’t find the answers anywhere.
I hope someone can help me.

Greetings from Germany
Jonas