Sample applications showing how to use SpriteKit on watchOS
- Objective-C
- RubyMotion
- show a triangle on the screen using a PNG
- rotate the triangle
- tap on the screen to start/stop the rotation
- Open the project with XCode and press cmd+r
open objective-c/SKWatch.xcodeproj
-
Pair a
Apple Watch Series 2 - 42mm
to a simulator -
Enter the project directory
cd rm/skwatch
- Install main app (iOS) dependencies
bundle
- Enter the watch app (watchOS) directory
cd sk_watch_game
- Install the watch app dependencies
bundle
- Go back to the main app directory
cd ..
[bundle exec] rake
May need to specify the iOS device id/name.
[bundle exec] rake device_name='iPhone 8'
[bundle exec] rake watch
May need to specify the iOS device id/name that contains the previously paired
Series 2 watch.
[bundle exec] rake watch device_name='iPhone 8'
- The Objective-C version was created from the iOS SpriteKit template. In the same project, the watchOS SpriteKit template was added as a new target.
- The Objective-C version contains a shared
TriangleNode
class used by the iOS and watchOS apps - The RubyMotion version contains a shared
TriangleNode
class used by the iOS and watchOS apps as well - The RubyMotion version contains a shared
TriangleRotationScene
(rm/skwatch/shared/scenes/triangle_rotation_scene.rb
) with the base code for adding the triangle PNG node andSKAction
. AtoggleRotateAction
method also toggles the rotation SKAction of theTriangleNode
. - The RubyMotion version iOS app contains a
GameController
without the use of storyboards. AGameController
instance is created and assigned as therootViewController
in the app delegate. - The Objective-C and RubyMotion versions contain the same SpriteKit game scenes for both the iOS app and the watchOS app.