Slick Forums

Discuss the Slick 2D Library
It is currently Sun Dec 09, 2018 11:42 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Mar 19, 2012 5:30 pm 
Offline

Joined: Sat Mar 17, 2012 5:50 pm
Posts: 5
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 347 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


Top
 Profile  
 
PostPosted: Wed Mar 21, 2012 7:23 am 
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.


Top
  
 
PostPosted: Wed Mar 21, 2012 11:15 am 
Offline

Joined: Sat Mar 17, 2012 5:50 pm
Posts: 5
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 )


Top
 Profile  
 
PostPosted: Sat Feb 14, 2015 10:27 pm 
Offline

Joined: Sat Feb 14, 2015 10:22 pm
Posts: 1
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group