Centered object anchor points #560

benstahl opened this Issue Nov 14, 2013 · 6 comments


None yet

4 participants


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 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.


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 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.


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 from Feature request: centered object anchor points to Centered object anchor points Sep 26, 2015
@bjorn bjorn added the Feature label Sep 26, 2015
jrmgx commented Nov 30, 2015

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


+1 this is just causing problems all around

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment