How does JSTileMap handle retina and ipad/iphone tile maps?

爷,独闯天下 提交于 2019-12-21 05:22:40

问题


I have created a basic tilemap using Tiled. I am using JSTileMap with SpriteKit to get the map in the scene. As I understood, JSTileMap (rather SKTexture) handles the retina and different devices automatically. I have not been able to produce good results so far, here is my setup:

I have one .tmx file created at a base resolution using map.png as it's tile set. The .tmx is present in the project but I purposely did not add map.png (I do not want to support non-retina iPhones).

In the project I only added the following .png's: map@2x~iphone.png (retina iPhones, using 48x48 tiles) map~ipad.png (non-retina iPads, using 48x48 tiles) map@2x~ipad.png (retina iPads, using 96x96 tiles)

Here are the results I get (after clean builds and reset content and settings on simulator):

Retina iPhone - tiles is wrong spots
iPad - no tilemap displayed, JSTileMap has parsing error
Retina iPad - tiles in wrong spots

If I use just a plain vanilla map.png (with 48x48 tiles):
Retina iPhone - tile map displays well but too large of course
iPad - tile map displays perfectly
Retina iPad - tile map display perfectly and is scaled.

I know I could just use a 24x24 tile map.png and apparently it will scale everything. I would prefer not to use scaled tile sets as the quality would suffer.

Thanks in advance.

E


回答1:


I was able to narrow down that SKTexture ignores the ~ipad file extension for the @2x file extension. This only created more headaches in trying to build a tile map system for iPhone retina, iPad, and iPad retina.

I have decided to avoid the problem all together. I am not using a universal app in my project now. I have a iPhone project and a separate iPad Project. This way all I need to do to work with Retina is the @2x file extension in each project.

This does fully work (much easier). A word to the wise to those only building for retina iPhones... half your tile height and width sizes in the .tmx files, otherwise you will have a great time trying to deal with the content scaling.




回答2:


Since you're using Sprite Kit and that requires iOS 7 there's actually no non-Retina iPhone to target anyway.

The thing in that instance is that you can't use @2x suffixed images without providing the same image without the @2x suffix. So the solution may be as simple as supplying the Retina iPhone images without the @2x suffix. You likely don't even need the ~iphone suffix either because the other two types of assets will only be used by the iPad devices.

This is based on an answer to a different question. I haven't personally verified it.



来源:https://stackoverflow.com/questions/21001806/how-does-jstilemap-handle-retina-and-ipad-iphone-tile-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!