Post

Replies

Boosts

Views

Activity

Reply to SpriteView > WatchOS 7
You can use SKScene on WatchOS, but curiously SKScene lacks didMove(..), so only sceneDidLoad() is available. https://developer.apple.com/documentation/spritekit/skscene/1519607-didmove I am having trouble with using SwiftUI as the wrapper and adding in gestures. It seems to lose the reference to the SKScene when SwiftUI does a full view update. I wanted to leave this here if anyone else is having trouble with showing a SKScene on WatchOS. There definitely are gaps that I feel make SwiftUI with SpriteKit untenable for real development. import SwiftUI import SpriteKit struct GameView: View {struct GameView: View {     var body: some View {         SpriteView(scene: gameScene)             .ignoresSafeArea()     }     var gameScene: GameScene {         let scene = GameScene(size: WKInterfaceDevice.current().screenBounds.size, something: 1)         scene.scaleMode = .fill         return scene     } } struct GameView_Previews: PreviewProvider {     static var previews: some View {         GameView()     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’21
Reply to Can an SKScene persist within SwiftUI?
Ok, I had a fundamental misunderstanding of the persistence and once I replaced the gameScene var with this it started working as expected. let gameScene = GameScene(size: WKInterfaceDevice.current().screenBounds.size, something: 1)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to SpriteView > WatchOS 7
You can use SKScene on WatchOS, but curiously SKScene lacks didMove(..), so only sceneDidLoad() is available. https://developer.apple.com/documentation/spritekit/skscene/1519607-didmove I am having trouble with using SwiftUI as the wrapper and adding in gestures. It seems to lose the reference to the SKScene when SwiftUI does a full view update. I wanted to leave this here if anyone else is having trouble with showing a SKScene on WatchOS. There definitely are gaps that I feel make SwiftUI with SpriteKit untenable for real development. import SwiftUI import SpriteKit struct GameView: View {struct GameView: View {     var body: some View {         SpriteView(scene: gameScene)             .ignoresSafeArea()     }     var gameScene: GameScene {         let scene = GameScene(size: WKInterfaceDevice.current().screenBounds.size, something: 1)         scene.scaleMode = .fill         return scene     } } struct GameView_Previews: PreviewProvider {     static var previews: some View {         GameView()     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21