4

I made a game for iOS using SpriteKit. Now I wanna make also the version for watchOS. I added a new target and then these files appear to me:

enter image description here

If I delete the sks file and then try to present a swift scene as I did for the iOS game the scene appears empty... So the only thing i could do is leave the scene.sks file as it was.

Can someone kindly explain to me how can to present a new scene.swift file in the interfaceController.swift without using the sks file?

Here is the InterfaceController.swift file that presents the sks scene, but I wanna present my own swift scene.

Code

Best Regards.

Doron Yakovlev Golani
  • 5,188
  • 9
  • 36
  • 60
I Don't Tell
  • 264
  • 1
  • 15
  • Welcome to StackOverflow Daniele, you can find all the examples you need in this [SO answer](http://stackoverflow.com/a/41208296/1894067) – Alessandro Ornano Jan 03 '17 at 19:12

1 Answers1

3

exchange the GameScene(filenamed:) with `YourScene(size:).

Your scenes are a subclass of SKView which have their primary initializers... here is the link to the one I showed:

https://developer.apple.com/reference/spritekit/skscene/1520435-init

So (filenamed:) is one initializer (for .sks) and (size:) is another initializer, for not having .sks. These initializers are the exact same kind of initializers you use for all of your own classes.

This just isn't readily apparent, because when you make your own GameScene: SKScene you don't specify initializers (because they are inherited from SKScene that you just subclassed from)

the video below also covers most of the necessary things for SK on AW.. it's timestamped to explain more of what you're doing:

https://youtu.be/REv-w2rBsng?t=1173

the info in the above video is virtually nowhere else that I could find, so I highly recommend you watch it from begin to end.


NOTE: (last I checked)

Your vanilla SKScenes won't work on the watch, because they lack certain functions (like touchesBegan) because you are no longer using an SKView to present your scene. So, you must use gesture recognizers..

Here explains how to get around that stuff:

TouchEvents in watchOS 3 SpriteKit?

Community
  • 1
  • 1
Fluidity
  • 3,985
  • 1
  • 13
  • 34