mapeditor / tiled

Flexible level editor
https://www.mapeditor.org/
Other
10.88k stars 1.74k forks source link

Unable to set origin coordinate for objects for GameMaker room export #1427

Closed kevintrepanier closed 6 years ago

kevintrepanier commented 7 years ago

It is frequent in GameMaker to use the center of an object as it's origin for easy placement and collisions. However in Tiled the origin seems to always be the top-left corner of the object.

Being able to set an origin point would be very useful.

bjorn commented 7 years ago

Hmm, I guess this could be implemented by supporting two custom tiles properties, originX and originY, and taking those into account when writing the positions of the instances. It would be a little cumbersome to make sure these values match the origin set on the sprite in GameMaker, of course.

And rather than having them as custom properties, it would be nice to actually support setting the origin for each tile in Tiled as well of course. This partly covered by #1323 (it still needs to be finished, and there's no convenient way to set it).

TrunXGIT commented 7 years ago

The missing originX and originY parameters for objects is the only reason why I'm not using Tiled for placing objects in Tiled for my current game project. It would be really great to ditch the build in level editor and use Tiled for everything realted to level building.

My work flow now is:

  1. Build a level only using the tileset in Tiled.
  2. Import it into GM
  3. Place hundreds of objects
  4. Find out that some parts of the level need a redesign
  5. Be a bit frustrated that the build in level editor doesn't support selecting and moving whole parts of a level.
  6. Go back to the Tiled level file in Tiled which only consists of the Tiles and make the adjustment
  7. Import it into GM again
  8. Do all the work with the objects again and hope you don't need to change something in the middle of a level.

Regarding the originX and originY parameters. Wouldn't it be possible to select the .gmx project file and read in all the already set values from the GM project and use them? Just a spontaneous idea.

Thanks for the great work!

bjorn commented 7 years ago

@TrunXGIT That workflow is so totally unacceptable. :-(

Reading in the existing object and sprite definitions from the GameMaker project would of course be ideal, but it won't be trivial since Tiled currently has no similar functionality. I think the closest thing would be to implement it as custom tileset format.

And then of course, the origin stuff still needs to be done as well.

In any case, I do hope to get around to it eventually. And contributions in code are welcome too of course!

kevintrepanier commented 7 years ago

@TrunXGIT If it can help : use "select-all" (ctrl+a) in the original room copy and then paste them all at once into the new room.

But yeah, there's several steps between Tiled and GM.

TrunXGIT commented 7 years ago

Thx for the tip kevintrepanier. In some cases it might be helpful, in others there would be still a lot of adjustments to do.

By the way, before somebody is thinking the GM exporter needs to be changed for the origin points. It only concerns the display coordinates of objects in the Tiled editor itself. Objects in GM don't have their own origin parameters. It's just the sprites assigned to the objects that have these parameters. Most likely this was already clear before, but just to make it sure ;)

bjorn commented 7 years ago

In some cases it might be helpful, in others there would be still a lot of adjustments to do.

Can you elaborate on what kind of adjustment? I noticed there are quite a bit of additional features in GameMaker rooms, like repeating image backgrounds and other options. Do you mean setting those up? I'd like to support as many of them as possible in a meaningful way in Tiled, to avoid the need for repeating setup in GameMaker after each export.

By the way, before somebody is thinking the GM exporter needs to be changed for the origin points. It only concerns the display coordinates of objects in the Tiled editor itself. Objects in GM don't have their own origin parameters. It's just the sprites assigned to the objects that have these parameters. Most likely this was already clear before, but just to make it sure ;)

Right, most of the work for supporting this will be to finish #1323, which is the equivalent of setting up the origin on a sprite in GameMaker.

kevintrepanier commented 7 years ago

Settings I usually have to change when importing or creating a new room :

There are also physics properties that can be set for the room for those who use it.

TrunXGIT commented 6 years ago

This seems to be solved now with the next update? :)

bjorn commented 6 years ago

For now the implemented solution to this is to support two additional custom properties, originX and originY, that you can set up to match the object origin you're using in GameMaker and then Tiled will adjust the exported position of the object accordingly. In doing this it even takes into account the object rotation and its flipped state (flipping translates to a negative scale in the export).

It's not ideal, but in combination with 152407249fba2008b5564e4208336882a0cf4495, which allows those properties to be specified on tiles or templates, you can at least avoid having to set up these properties for each instance.

Settings I usually have to change when importing or creating a new room:

@kevintrepanier I guess you have found out in the meantime that most of those settings can actually be specified in Tiled using custom properties. All except the backgrounds, which are still not supported (I think it would make sense to export the image layers as backgrounds). You can now also find these properties documented at http://doc.mapeditor.org/en/latest/manual/export/#gamemaker-studio-1-4. And now of course the new properties added in 9e1023eabb6add3989ce21ee148c6ef46fc50abd should still be documented...

bjorn commented 6 years ago

Documentation added in a70489adfbdf28077b47ec6e3a0e9864c511c334! It will be live soon at the above link.

kevintrepanier commented 6 years ago

I've downloaded the Alpha 4 snapshot (Version 2017.09.13) and tested the originX and originY custom properties for GameMaker but it does not seem to work properly. In GameMaker, the X is equal to the X in Tiled and the Y is offsetted by -32 pixels (32 being my object's height). The originX and originY does not seem to affect the X and Y at all (I've tried changing their value but it does not change the result).

Side note : I also have an object that I've long ago deleted in Tiled but that keeps appearing in my imports in GameMaker. I can't reproduce that bug but it makes me wonder if there is other residual informations that might cause the origin problem?

test_originxy

bjorn commented 6 years ago

I've downloaded the Alpha 4 snapshot (Version 2017.09.13) and tested the originX and originY custom properties for GameMaker but it does not seem to work properly.

That is because the release date of the Alpha 4 snapshot is before this functionality was implemented (6 days ago). These custom properties will be supported starting with the Alpha 5 snapshot, which I plan to release today.

Side note : I also have an object that I've long ago deleted in Tiled but that keeps appearing in my imports in GameMaker. I can't reproduce that bug but it makes me wonder if there is other residual informations that might cause the origin problem?

I have no idea how something like that could happen. What is deleted in Tiled doesn't show up in the exported file, so maybe this object was coming from somewhere else? Or maybe you missed a hidden object?

kevintrepanier commented 6 years ago

Ok, thanks for the info. Looking forward to test it in the new snapshot!

You are right about the other "residual" object. It was individually hidden in a layer I didn't expect to find it. So no problems here.

bjorn commented 6 years ago

Ok, thanks for the info. Looking forward to test it in the new snapshot!

And it's out! https://thorbjorn.itch.io/tiled/devlog/11050/tiled-11-alpha5-and-documentation :-)

kevintrepanier commented 6 years ago

Tested and it's working perfectly! Thanks a lot!