Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for GID attribute & Issue 1477 Fix #430

Merged
merged 4 commits into from Jun 2, 2013
Merged

Add support for GID attribute & Issue 1477 Fix #430

merged 4 commits into from Jun 2, 2013

Conversation

dylanetaft
Copy link
Contributor

So, long story short
mapeditor/tiled#91

In Tiled, the y coordinate value is inconsistent between rectangle objects vs tile objects.
For example, set your tile size to 32x32 in tiled.
Add an object layer.
Add a rect to the object layer, position 0,0, width 1, height 1. It will be in the upper left corner of the map.
Add a tile object from your tileset. The map starts at 0,1.
I tried building the latest nightly of Tiled from GIT, the issue is still there.

However, what is the most elegant way to deal with with LibGDX?
x and y are added to the Object properties. This issue only occurs with Tiled map objects that are "tile" based, where they have an image. This uses the "gid" attribute in XML for Tiled.

So, a programmer, if gid is exposed, now has a way to deal with this. They can offset the object up 1 tile.

This should be a harmless change to support it. Additionally, this gives the flexibility to assign an image to a Tiled map object based on GID instead of doing something else, if someone wanted to.

If this is inappropriate, setting a property manually on such an object is a workaround, ie, "hasYCoordBug" or something similar.

The underlying issue is that there's no way to determine once you load a map with TMXMapLoader what is a "rect" and what is a "tile" based object. This gives a way, if it has a gid, it's a "tile" based object.

@dylanetaft
Copy link
Contributor Author

I received an email from Thorbjørn, developer of Tiled. It's intentional, the origin of tile based objects in Tiled is the lower left, which is different than rectangle based objects. So there should be a way to determine if a map object is a rectangle object or a tile based object as they need to be positioned differently.

So, we could either expose GID, so it's available for the programmer to do what they want with, or create TextureMapObjects if the object's GID is set. Exposing GID is easy and won't break anything.

It probably doesn't make a lot of sense to create TextureMapObject objects, and it would break people if they reference gids of images not available in their run directory. Plus, I doubt we'd want the map renderer to render object layers? Object layers are just for the programmer to do what they want with - not to render by default. So we don't want to load textures. Right?

@MobiDevelop
Copy link
Member

Can you also make the change in the AtlasTmxMapLoader (both core and GWT version)?

@dylanetaft dylanetaft closed this Jun 2, 2013
@dylanetaft dylanetaft reopened this Jun 2, 2013
@dylanetaft
Copy link
Contributor Author

Well, the changes are in. Still trying to get the hang of git and github. How's this? Just created a test project that uses AtlasTmxMapLoader, and the change is working fine.

I don't quite understand why it's showing that I want to commit the merge I did in my fork to sync it with upstream. I only want to submit my changes to the two AtlasTmxMapLoader.java files and the two TmxMapLoader.java files.

Edit: I think I know what I need to do. I need to create a branch on my repo, and only make my changes there, and submit the pull off that? Can you cherry pick 51f2d1f and 801bac4 from this pull? Or, should I resubmit?

@MobiDevelop
Copy link
Member

I can cherry pick probably. If I don't merge this by tomorrow then bug me about it. On my phone now.

@dylanetaft
Copy link
Contributor Author

Fixed my tree, so it should be OK to just pull now.

MobiDevelop added a commit that referenced this pull request Jun 2, 2013
Add support for GID attribute & Issue 1477 Fix
@MobiDevelop MobiDevelop merged commit 6bef743 into libgdx:master Jun 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants