-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Comments
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. |
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). |
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. |
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. |
Configurable anchor points would be a big plus here too :) |
+1 this is just causing problems all around |
+1 for configurable anchor points! This is really creating some headaches for me |
It's been years since it has been suggested. Has it been implemented now, already? |
@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:
|
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).
The text was updated successfully, but these errors were encountered: