2D Toolkit Forum

2D Toolkit => Support => Topic started by: madclouds on August 04, 2015, 06:23:13 pm

Title: CurrentPlatform - Recommended way to set Platform Specific Sprite Collections
Post by: madclouds on August 04, 2015, 06:23:13 pm
Hello,

I was wondering what the suggested way to handle platform specific sprite collections would be.  I went through the tutorial here - http://www.2dtoolkit.com/doc/2.5/advanced/platform_specific_sprite_collections.html - but it doesn't suggest how to select the CurrentPlatform.  Searching the forms, I found this code:

Code: [Select]
Application.targetFrameRate = 60;
 
if(Screen.width > 1136) {
tk2dSystem.CurrentPlatform = "4x";
}
else if( Screen.width > 480 ) {
tk2dSystem.CurrentPlatform = "2x";
}
else {
tk2dSystem.CurrentPlatform = "1x";
}
Debug.Log("CURRENT PLATFORM (main) : " + tk2dSystem.CurrentPlatform );
Debug.Log("Device data:");
Debug.Log("Screen resolution: " + Screen.width + " x " + Screen.height );
 

I saw another technique that monitored the device type and did a string match on the device to set the current platform, but that sounds brittle.

Is checking the Screen.width the best technique?  If so, I'd recommend adding that info to the tutorial page for other people to find.

Thanks for any feedback.
Title: Re: CurrentPlatform - Recommended way to set Platform Specific Sprite Collections
Post by: unikronsoftware on August 05, 2015, 10:35:40 am
Its up to you, thats why there isn't any guide. You might want 2x sprites when the screen height exceeds a certain amount - the constraints are not set in stone and there isn't one way to do it - it really is up to you what you want to do there.