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

Centered object anchor points #560

Open
benstahl opened this issue Nov 14, 2013 · 9 comments
Open

Centered object anchor points #560

benstahl opened this issue Nov 14, 2013 · 9 comments
Labels
feature It's a feature, not a bug.

Comments

@benstahl
Copy link

Currently, when an Object such as an ellipse or square are rotated, the position gets affected because Tiled sets the anchor point of the object to one of the corners instead of the center. It would be very useful to be able to set the anchor point of these objects to the center (I would even argue this should be the default, at least for circles and squares). That way, you can place an object on a grid point and rotate it without the position being affected. For example, I want to place a "crate" (square) placeholder object at grid point 16,12, then rotate it 45 degrees. When I read the .tmx file, the position should still be at 16,12 (currently that is not the case).

@bjorn
Copy link
Member

bjorn commented Nov 15, 2013

So you are requesting the rotation anchor to be somewhere else than the position of the object? Or would you also be fine with an option to center tiles on their position rather than having their position in the bottom-left?

See also issue #539, which is somewhat related.

@benstahl
Copy link
Author

I guess an arbitrary anchor would be more flexible, but a centered anchor would probably work for 90%+ of the use cases I can think of. I just want to be able to rotate objects (like an ellipse or square poly) without their position changing. I'm using polygonal objects as placeholders on a layer, then I read them in my game and make game objects from those (which use the position and rotation properties from Tiled).

Reading issue #539, it is related, and indeed rotating using the rotate tool as opposed to setting the property rotates the object around its center, as I want. However, it is very difficult if not impossible to achieve exact degree rotations using the interactive tool. If I want something to be rotated exactly 45 degrees, I have to set that with the property, which again, does NOT rotate around the center and will change the x, y position of the object (which will now be off my grid). So it seems kind of odd there are two different coordinate systems being used for rotation, one using the center point and one using a corner point.

Bottom line is I would like objects to have a centered anchor point, used for both translations and rotations, and the x,y position values (both the grid and the exported values multiplied by the scale factor) would always reflect the location of that anchor point. Or, for a little more flexibility, maybe allow user to set the anchor point of an object to center, UL, UR, LL, or LR, but in any case, use the same point for any kind of rotation or transform so rotation isn't affecting position (ie. the anchor point IS the position, whether rotated or not).

@bjorn
Copy link
Member

bjorn commented Nov 16, 2013

Hmm, as I explained before at issue #539, the rotation applies around the object position, and changing the rotation property directly will not change that position. There's no two coordinate systems being used, the rotation always applies around the object position (which is the bottom-left for tile objects). The rotation tool, however, rotates around the center of all selected objects because this is more convenient in general (and for doing that it is necessary to change the object position).

If I understand you correctly it would be more convenient for your game/engine if the object would be centered on its position rather than bottom-left aligned to it. There are also many people asking for the objects to align to their position with the top-left. While I certainly consider adding an option for this, supposing I had time for it and there were not more interesting things to do, it should be relatively straight-forward to convert the position from one anchor point to another while loading or interpreting the map. In the end it's all the same and just a way to specify where and how an object is displayed, right?

Btw, you say you are using polygonal objects. That case is somewhat special since polygons do not really have a center point. Polygons initialize their position based on the first placed point and I'm not sure how an eventual alignment option could be applied to polygons. If the position would depend on the bounding box, for example, it would need to change around while moving the nodes of the polygon and this would be especially tricky to deal with when the polygon was rotated.

@benstahl
Copy link
Author

Yeah, I agree it is trickier for arbitrary-point polygon objects. Maybe do a simple point average for a center point (i.e. center of gravity). Or maybe it's just not an option for polygonal objects. Center-anchored rotation would be more useful to squares/rectangles, where rotation (using the interactive tool or entering an angle manually) would not affect the position of the object.

@bjorn bjorn changed the title Feature request: centered object anchor points Centered object anchor points Sep 26, 2015
@bjorn bjorn added the feature It's a feature, not a bug. label Sep 26, 2015
@jrmgx
Copy link

jrmgx commented Nov 30, 2015

Configurable anchor points would be a big plus here too :)

@gotenxds
Copy link

+1 this is just causing problems all around

@besserwisser
Copy link

+1 for configurable anchor points! This is really creating some headaches for me

@martin-braun
Copy link

It's been years since it has been suggested. Has it been implemented now, already?

@bjorn
Copy link
Member

bjorn commented Feb 17, 2018

@l-Marty-l It has not been implemented yet, which is why this issue is still open. There are many suggestions open for years now, since the project in general is almost 10 years old. But I don't prioritize issues because they are old. Rather, issues get priority if:

  1. Someone is willing to work on them. This generally gives them the highest priority, since I try not to let people wait for code reviews and I want to encourage people to contribute.
  2. Someone is willing to sponsor them. Sometimes there are people who really miss a certain feature, and they can choose to become a $200/month patron. I'm currently committed to implement three other major improvements due to this.
  3. Finally I work on whatever I believe is most important to move the project forward. There are hundreds of issues to choose from, plus a lot of things for which no issue exists. Certain big issues that I would like to get around to are mentioned on the Roadmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
None yet
Development

No branches or pull requests

6 participants