Hello Guest

Author Topic: Platform Specific setup  (Read 6635 times)

fxstronster

  • Newbie
  • *
  • Posts: 3
    • View Profile
Platform Specific setup
« on: October 18, 2012, 02:42:23 pm »
Howdy, I'm playing "1.8 final" and am struggling to understand some of the finer points of the tutorial at:
http://www.unikronsoftware.com/2dtoolkit/doc/advanced/platform_specific_sprite_collections.html

Specifically, I'm making a sample app with a 64x64 image to show on non-retina iOS devices but want to show a 256x256 image on a retina iOS device.  I'm wonder if this is accomplished with a single Sprite Collection that holds both textures or two Sprite collections; one set to x1 and one set to x2.

In other words:  Is a single Sprite Collection suppose to support multiple resolutions (e.g., x1 and x2) or is one Sprite Collection suppose to support x1 and another support x2 and somehow, via code, they are dynamically swapped at run-time?


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Platform Specific setup
« Reply #1 on: October 18, 2012, 04:29:30 pm »
First - If you have a normal image at 64x64, the retina one should be 128x128 (2x). It'll be 4x if you want it to be 256x256.

You create one sprite collection and start with all the 1x sprites and go ahead and set up your scene. After that follow the steps under the "Ideal workflow" heading in that tutorial. That will set it up and tell it about the 2x sprites. You don't have to deal with any other sprite collections.

Everything is done automatically, you don't have to do anything apart from
Code: [Select]
tk2dSystem.CurrentPlatform = "2x"; or something like that on startup to tell it which variant to load when requested.

fxstronster

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Platform Specific setup
« Reply #2 on: October 22, 2012, 04:09:35 pm »
Thanks for the reply unikron.; you are right about the 64x64 vs 128x128 (my bad for throwing out some random power of 2's)

What I'm wondering is if it's possible to use two different spritesheets; instead of all pulling from the same sheet have one spritesheet contain the 64x64 images and another have the 128x128 images.  That way each Sprite sheet can exist in a platform specific  bundle; only loaded into memory if it's the running platform.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Platform Specific setup
« Reply #3 on: October 22, 2012, 04:44:33 pm »
That's pretty much what it does now.

fxstronster

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Platform Specific setup
« Reply #4 on: October 22, 2012, 07:51:57 pm »
So in theory, it should be possible to have 2dtoolkit setup these different SpriteSheets and then use a plugin like the "Multiplatform Toolkit" ( http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,478.0.html ) to ensure only the SpriteSheet for the proper platform is loaded at runtime?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Platform Specific setup
« Reply #5 on: October 22, 2012, 10:10:22 pm »
That wouldn't use the 1.8 feature, but yeah if you want to you could do that.

If you set up platform specific sprite collections, only the one appropriate to the current platform will be loaded in. Each one has its own atlas, so only the active atlas will be loaded.