marshallward / TiledSharp

C# library for parsing and importing TMX and TSX files generated by Tiled, a tile map generation tool
http://marshallward.github.io/TiledSharp
Apache License 2.0
328 stars 87 forks source link

Object layers throwing exception #9

Closed Josh1billion closed 9 years ago

Josh1billion commented 9 years ago

When I try to load a map that contains at least one object layer, an exception gets thrown. The exception appears to be related to the drawing order in some way.

To reproduce:

  1. Create a new map. Add a tile layer and place some tiles (probably unnecessary, but just for good measure).
  2. Add an object layer.
  3. On that object layer, place an object (I created a circle, gave it a name and a type).
  4. Save the map, and attempt to load it with TiledSharp.
  5. An exception should get thrown in ObjectGroup.cs, in the TmxObjectGroup constructor.

For the time being, I was able to get the map to load by editing ObjectGroup.cs and removing the offending code, replacing it with just this simple line: DrawOrder = DrawOrderType.TopDown;.

marshallward commented 9 years ago

It looks like the current code assumes that "draworder" is present, which is similar to the other bugs that were present. I'll add a "null == True" check as with the other versions.

marshallward commented 9 years ago

I pushed a change to master that removed the TryGetValue method, can you give it a try now? (BTW I really do need to get the testing framework set up!)

Josh1billion commented 9 years ago

Yup, it works now. Thanks for the quick fix. :+1: