Reputation: 47
I'm trying to make a widget game, is it possible to use SpriteKit within a Today Extension?. I've been searching for similar posts but I've only found a question related to using SpriteKit in a AppleWatch extension.
Upvotes: 3
Views: 601
Reputation: 33
I made a framework with the intention to solve this problem some months ago, link here. I haven't had time to test it properly in iOS 11, so there might be some new bugs.
The only working solution I found to use SpriteKit with Today Extensions was to create the SKView and present the scene in viewWillTransition(to size:with coordinator:)
. This is necessary because Today Extensions have a different life cycle than a normal application, look at these iOS Widget Gotchas to get more detailed information on how this works.
EDIT: The correct method to setup these things might now be viewWillAppear in iOS 11, but it might be necessary to do some testing.
Another really important thing to consider when creating widget games is that you have very little memory(16mb if I recall correctly) to build your game with. You have to reduce your memory usage at all costs, otherwise the widget will crash and display a message telling you that it was unable to load.
Upvotes: 0
Reputation: 68
I also working on some game in the today screen. So far I have found 3 solutions which working solid:
The problem on solution 2 is, that it's very unreliable. Even calling regularly completionHandler!(NCUpdateResult.newData)
has not worked.
So it's just the limited usage of SKAction at the end which has bring a lot.
Solution 3 is also good and works quite solid. Of course you must reinvent the wheel and can not use the nice features of SpriteKit. But because I've used this approach already in watchOS games, it was not much effort to use in Extensions.
I recommend solution 3 because you have full control and it works solid.
Upvotes: 2
Reputation: 86
I tried develop game in spriteKit for ios today extension, added SKViews to UIView, but it did not work. It seems like scene not loading in today extensions. I think it is not possible - use spriteKit in today extension. But i found good solution - using UIKit instead spriteKit. It is very powerfull framework for game developing, and i think Steve game developing via UIKit. You can check adding dynamics via UIKit in this sample: https://www.raywenderlich.com/50197/uikit-dynamics-tutorial
Also i can upload sample of using UIKit in today extension game developing on github if needed.
Upvotes: 0
Reputation: 73
It is definitely possible. I think you are aiming to build something like the popular "Steve" Widget Game, and I believe that is a SpriteKit Game built into a Today Extension.
To begin, I would suggest to fully understand Today Extensions and it's limits and then fully understanding SpriteKit and the limits that it has.
Something you really want to focus on is making an extremely efficient piece of app. All around, from the actual code and how your code runs. This is due to the fact that Today Extensions are not really apps but "extensions" to your device so if you have a game that is graphics intensive or memory intensive, your app will crash.
Upvotes: 1