I am making a landscape universal game with Spritekit and Swift in Xcode 6.1. I have been researching about how to make a universal app, and there seems to be a lot to do in regards to layout so that your game looks the same across all devices.
I have read that you can do this by defining a "playable area" in which you put all your game features into. The link below shows a image explaining the playable area idea.
http://cdn5.raywenderlich.com/wp-content/uploads/2013/09/Aspect-Ratio-Diff.jpg
Apart from the 1 tutorial I have found online talking about this, (which wasn't for Swift) I cannot find anything about how to actually "define" a playable area for Swift in Spritekit.
Is there a way I can create a rectangle, lets say on the iPhone 6 for example, so that it will cover all devices as long as I build my game within that rectangle?
Basically how do I define a "playable area" so that I can see the boundaries that I have to build my app within? Like in the linked picture?
To make the layout appear the same on every device , assuming u support iPhone 5 and above only . You can make use of .Aspectfill under your GameViewController to scale the scene to fit all the resolutions. This means that you will be using the iOS 5 simulator and that you will relinquish support of iPhone 4s.
The best way to define a playable area would be to either create a rectangle node that encompasses a certain area while ensuring that your physics world is showing physics for testing.
If you want to build for each screen size natively, you would have to adjust your content manually as technically , devices such as the iPhone 6 plus for example are designed so you can see more things.
Related
I am currently making a classic snake game app.
The app fits and works on all iPhones however when I test on any iPad the lettering is off the screen and so is the game screen.
Is there anyway to adjust the proportion or have it depend on what device you are using?
I was unable to find much help online when looking for this question. (first image is an iPhone 7, and the second is an iPad Air 2.
What you're looking for is Adaptive User Interfaces. You should be able to have different layouts for different device sizes using a single storyboard.
You can also change values programatically in your code according to the screen size.
I am developing a 2d game. I am on step where i have to make score things and button. I am doing this by canvas. It working fine on unity but when i test that on simulator all things become small and not showing in actual size. Can any one help me in this case.
In Unity
in Simulator
Try to change Canvas settings like below,
And for device like focus, change preview in Game tab from Free Aspect to any defined resolution. Like,
Then set sizes of your UI elements.
I am newbie in game development,currently I am using the sprite-kit framework. I have added scene on SKView. On scene I am setting images to SKSpriteNode and building it on iPhone 6 plus simulator, its looking perfect on it,but problem is that, when i build it on lower version like iPhone 5s,4 or 3 ,the some part of images are going outside the simulator screen.I have tried all the scale modes for scene but its not working.
You can use the property of SKScene called scaleMode. You may want to use SKSceneScaleModeFill or SKSceneScaleModeResizeFill.
More information here
I'm developing a new ios 8 application using SpriteKit. Recently I read a lot about adaptive UI but found no way to implement it with SpriteKit.
Suppose for example that I programmatically create a subclass of SKNode, call it MyNode.
In interface builder there is nothing that lets me put on the screen the node I just created.
I found on raywenderlich a snippet of code that checkes whether the app is running in iPad or iPhone and resizes a playable area of 320x480 opportunely.
Is there a method to adapt the ui with ib? Or should I do this programmatically via that snippet? Thanks.
This is an example of what I mean. These are the app screens in iPad and iPhone. How do you think the developer achieved the goal?
iPad
iPhone
I am developing a game for the app store and have been using Sprite Kit. In Sprite Kit to have the game work on both the iPhone and the iPad I set the SKScene's scaleMode=SKSceneScaleModeAspectFill and made the screen proportions so it would fit the iPhone 4&5 screens as well as the iPad and this has worked well. Now I am building the menus for the app, but I am not using Sprite Kit for this. Instead I am using Collection Views, Buttons, images, etc. I am not seeing a similar property to scale the view to a certain size depending on what device I am on. Since I am using images for all of my buttons, ideally just proportionately scaling everything would be the simplest way to achieve what I am looking for. Am I missing something as far as how best to proceed with this? Thanks in advance.
You are describing Auto Layout. It is the feature specifically designed for this very purpose, i.e. to change sizes and distances of interface objects in response to the fact that the screen is a different size.
https://developer.apple.com/library/ios/documentation/userexperience/conceptual/AutolayoutPG/Introduction/Introduction.html
However, for a size difference as great as the iPad vs. the iPhone, if you have a universal app, it sometimes makes sense to design two different interfaces. It is easy to set up the Info.plist or your initial code to load the correct interface depending on which device type this turns out to be at runtime. In fact, if you start by making a Universal app, the project will simply come with two storyboards, one for iPhone and one for iPad, which are loaded automatically.
Another option (which didn't occur to me at first because I don't write these kinds of game) is to scale a superview by applying a view transform (i.e. set its transform to a scale transform). That scales the view's coordinate system, so all its subviews will change to match, just like a drawing.