I have a question regarding universal gaming assets and the absolute positioning of SKNodes in the Sprite Kit (iOS 8 +).
I will try to present my problem in the following example:
Imagine a top-down 2D game with SKSpriteNode , which is a home. There are many SKSpriteNode children in the SKSpriteNode , which are chairs, a desk, a sofa, etc.
I have 3 versions of home property:
1x - 200 x 200px (Non-Mesh iPads)2x - 400 x 400px (Retina iPhones and iPads),3x - 600 x 600px (iPhone 6 Plus).
Attention! : Positions of child nodes (chairs, table, etc.) Defined in the .plist file. Something like this (JSON representation):
children: [ { position = {20,20}; }, ... ]
Since the position is determined in points rather than pixels, everything becomes positioned, as expected, in accordance with the scale of the device’s screen. For 1x devices, the position remains {20,20} , for 2x - {40,40} , and for 3x position is {60,60} .
Problem
The problem is that 200x200px and 400x400px assets are small for iPad devices in order to achieve the same appearance on all devices.
Question
How to successfully represent / import assets in such a way that I achieve the same (if not the same) appearance of devices / screen sizes without disrupting the location of child nodes?
My occupation:
Take 1 :
I could just use existing 400x400px resources for iPad devices without a retina and 600x600px assets on Retina iPad devices for the home node, but the location of the child nodes would be disrupted. This is due to the fact that the position value of the child has not changed and will still be {20,20} and {40,40} for iPad devices, respectively, while assets will be larger. This will lead to inaccurate child positions in relation to the home node.
Take 2 :
I could also scale the SKScene size (zoom effect) using the usual 200x200px and 400x400px for iPad devices, respectively. This works, and it keeps the work of the child nodes, but the scene / asset playback quality is not as good as it should be. In addition, it looks like a hack, and we do not want it.
Take 3 :
I could also use twice as large assets for iPad devices and double the position of child nodes at runtime. In this case, I would use the 400x400px resource for iPad devices without a retina and the new 800x800px resource for iPad Retina devices. Although it looks great and supports working with child nodes, it looks like a really big position for storing node children at runtime:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { position.x *= 2.0f; position.y *= 2.0f; }
Thanks for taking the time to read the question!