Bill
Bill

Reputation: 123

dealing with different screensizes when using tiled map files (tmx)

I'm trying to learn spritekit and I'm a little confused by something. I know that I need to have @2 image files which need to be double the size of the standard ones and that once I name them properly xcode will deal with the rest. But, when dealing with tiled, do I need tiled files that are level1.tmx and [email protected]

So here is what I did as a test today:

  1. created two tilesheets, one was 32x32 and the other is 64x64 (the 2x).
  2. create two levels in tiled, one was 64x64 tile sizes and the level size was 2048x1536 (the 2x one). I used the 64x64 tiles on that one. The other level I created was the exact same, but I created it with 32x32 tile size, which made the level size 1024x768 and I used the tilesheet that was 32x32 on it.

So now I have two tmx files and two spritesheets, for one level, on the ipad.

Am I doing this correctly? Once I start doing the iphone I will have 4 or maybe 6 sets for each level?

I assume xcode won't work the same way with tmx files if I name them [email protected], right? If not and assuming everything I'm doing above is correct, how to do load the correct tmx file? Do I need to check for device type, then resolution and load my map file based on that for each level?

I think maybe I'm not doing this right so I wanted to stop here and ask before I get any further.

Upvotes: 1

Views: 118

Answers (1)

Skyler Lauren
Skyler Lauren

Reputation: 3812

TMX files are not loaded automatically in iOS so I am guessing you are either using the SKAToolKit or the JSTileMap one of the two most popular to my knowledge. Myself and other Sprite Kit Alliance members put together the SKAToolKit so I think I can answer your questions from that point of view because it should be similar for JSTileMap too.

The short answer is build your map using 1x assets, but provide images for standard and retina in Xcode.

First you create your map using 1x assets. When the map is loaded it uses points not pixels. So for example if you make a 32x32 pixel tile map it will be treated as a 32x32 point map. When the sprites are created it pulls in the correct image based on device. If an image is named tree.png and is 32x32 it will take up the space of a 32x32(point) tile. If you have an image called [email protected] 64x64 iOS will use that for retina devices. Because it is an @2x image it will take up 32x32(points) but will be 64x64 pixels.

Hopefully that makes some sense. If not let me know.

Upvotes: 2

Related Questions