My app layout is too complex to work with auto layout. I wondering how to create different scenes within a spritekit template in order to customize and ensure the game will look properly on every device. In a single view application this is easy because I only have to use multiple storyboards. While using sprite kit however,there are scenes and I was wondering how to go about creating the game for every individual screen as opposed to using auto layout. What should i do?
Sprite Kit scenes are presented by a special kind of UIView, SKView, and do not use Auto Layout. Only UIKit does - Auto Layout handles the arrangement of UIViews.
Try looking into Xcode's Level Editor (which is like Interface Builder, only for Sprite Kit). I've found a Swift tutorial which might be appropriate. Try playing around with it for a little bit.
If you would like a more specific answer, please be more specific about the screens/methods you are planning on using.
Related
If you make a new game template project in Xcode, the default GameViewController will use the following initializer to instantiate the game scene:
let scene = SKScene(fileNamed: "GameScene")
The initializer's use in the template file suggests that this is Apple's recommended way for creating an SKScene. However, I have seen many examples on Stack Overflow that use the init(size:) initializer or simply SKScene().
I am wondering which is the best way to create an instance of SKScene and what are the advantages/disadvantages of each way, as well as various pitfalls to look out for when using one approach versus another.
My reason for asking is that I used init(fileNamed:) to create my game's scene and build level 1. When I later tried to create another instance of the scene for level 2 using init(size:), I ran into problems. Namely, some positional calculations using UIScreen and the scene's frame seem to produce different results if I create the scene using init(size:) instead of init(fileNamed:).
In a more general sense, I would like to hear the opinion of someone who is very familiar with using iOS and SpriteKit about their preferred way of initializing a new SKScene and the pros & cons of using different approaches.
I very strongly recommend not using init(size:) when it comes to creating your scenes that you use as a part of your game. You really should try to keep design separate from structure. This allows for you to change how the layout of your game is, without changing any code, thus reducing the potential for bugs.
With that being said, there is a very common practice tutorials use that looks like this init(size:view.size). This one causes all kinds of trouble with game designers, and destroys the simple handling of multiple devices that SpriteKit offers. People tend to end up in a 0..1 coordinate system, placing divides everywhere when positioning their nodes, and this too leads to bugs because people may end up forgetting a divide somewhere, or using width when they meant height.
SKScenes have 4 scale modes that handle how a scene should look on every device, and it should always be taken into consideration when developing a game with this tool. It really should be the first thing that gets discussed so that people can understand the power behind it.
The only time I would recommend using init(size:) is when you need to create a dynamic scene that cannot be achieved via the sprite kit builder, and when you already have a static size of the window established.
I am trying to integrate any gaming kit (like scenekit or sprite kit) inside my utility based single view application , so is it possible to integrate any game kit with single view application what is the approach to start integrating game using objective c/swift. i can develop simple games using UIKit framework, but i want to try more interesting things in my apps. so what is the best option to integrate gaming in single view applications.
Thanks for your advice
To answer this, Yes you can. All it takes is adding a view to your view controller, giving it the custom SKView class, then inside of your view controller code, use the view that is attached with the SKView class to present the scene that you want to be working with.
Weird crazy question I know. My current setup is a SCNScene with a camera controlled by the device's gyroscope. I'm able to add and light normal nodes, however I would like to add 2D UIView objects into the scene like UITextViews or maybe some buttons. The views would need to be inside the scene and thus become no longer visible if the camera moves away from them.
Firstly, is this even possible? Or would this be way more difficult to implement than rebuilding an editable textview as a node? Could this be achieved by categories or...?
I just talked to the scenekit people here at WWDC. He said that as of now it is completly impossible to do it in a nice, functional way. The only options he offered as a possible solution is to create the UIView element somewhere off screen or behind the scene and continuously take screenshots of the object and apply those images as a texture to a SCNNode. He also pointed out the performance will be very poor with this because taking screenshots is heavy and you can't get going very quick with it. So I guess this is a no-go until UIView adds support because, according to the engineer, it's impossible to implement this because of a UIView limitation and not a SceneKit one.
I am in talks with a client to do an app, but in it, they are wanting it to revolve around a little character that follows you throughout the app (think Clippy, from the old days of Microsoft Word :)).
One thought I had was, can I use an SKSprite/Node inside an iOS app not using the SpriteKit framework?
Or is this a matter of animating through an array of UIImages?
Those were my first thoughts - does anyone know the best direction to go in for something like this? I need basic animations for a character throughout the whole app.
Depending on the detail of animation needed, you could do it with just CoreAnimation and possibly selectively choosing the image to display in an UIImageView. For example, see the answers to this question: rotate a UIView around its center but several times
Simple answer is, No, out of the box you can't use a class from a framework and choose to not use the framework. Though I'm not exactly sure what that question means. An SKSpriteNode renders via an SKScene node, and an SKScene node renders via an SKView, which is rendered by a View Controller.
You could do something fancy like dedicate the SKView as only part of the screen, and have a standard UIKit view as the other part, or only have the SKView appear on the screen when you needed it I guess.
I want to create a simple game, and as I understand it OpenGL will make that happen but could I make the menu, high score list and every thing except the game with regular xcode?
For instance, for Windows Phone (where im comming from) you could create XAML/DirectX where you totally could make the menu in xaml/cs and then the game in directx
Yes, the main view element in iOS is called an UIView and you use it to present openGL content on it. This results in being able to overlay it with any other views, subviews, put it in a superview, have multiple views with openGL content... All the events such as touches work as well. In summery implementing openGL in iOS UIView will simply override the visual content of the view leaving rest of the functionality as it is.