Slick Forums
http://slick.ninjacave.com/forum/

RFE / Patch: Flipping and Rotating Tiles in Tiled Maps
http://slick.ninjacave.com/forum/viewtopic.php?f=1&t=4723
Page 1 of 1

Author:  Wilson [ Mon Mar 19, 2012 5:30 pm ]
Post subject:  RFE / Patch: Flipping and Rotating Tiles in Tiled Maps

Hi there,

Tiled supports flipping and rotating tiles, but those tiles are not displayed at all in Slick. Tiled encodes this information in the Most significant bits of the Tile Id, so any Loader unaware of this will not find the Tiles.

I have patched Slick to read and correctly display flipped and rotated tiles:
Attachment:
File comment: Patch based against SVN revision 1560
FlipRotate.zip [1.25 KiB]
Downloaded 412 times

In some parts the code is not the cleanest, but it works. :D

Layer.getTileId still returns the Tile Id with the Flipping Bits set. Whether this is desirable needs to be discussed.

Implementation details: I decided not to cache the Flipping/Rotating booleans but to parse them out of the Id when the Tile needs to be rendered, because the performance gains would only be minimal, compared to a huge increase in memory usage.



Greetings,
Wilson

Author:  liamzebedee [ Wed Mar 21, 2012 7:23 am ]
Post subject:  Re: RFE / Patch: Flipping and Rotating Tiles in Tiled Maps

Thanks for this @Wilson, I've merged this into my local repo and will be in the main branch soon. Could I ask, what are the different byte values for different transforms in your new drawEmbedded method?

e.g. what byte value is for rotate, flipX and flipY.

Author:  Wilson [ Wed Mar 21, 2012 11:15 am ]
Post subject:  Re: RFE / Patch: Flipping and Rotating Tiles in Tiled Maps

The least significant bit (0x01) is Rotation, or to be more specific flipping the top left corner with the bottom right.
The second least significant bit (0x02) is Flip Y.
The third least significant bit (0x04) is Flip X.

It is the exact same thing TilED is doing, only shifted 29 bits to the right.

Example:
To rotate 90° clockwise you would set the rotation bit and the Flip Y bit. (If i am not mistaken :D )

Author:  Fudgyking [ Sat Feb 14, 2015 10:27 pm ]
Post subject:  Re: RFE / Patch: Flipping and Rotating Tiles in Tiled Maps

I started using Slick2D recently and I use TiledMapEditor to make my maps. At first, rotated tiles were shown all the time, but suddenly, they all became invisible. The fix you made is no longer available but I really need it.

If it's already supposed to be patched, is there a way that this could actually be my fault?

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/