LoginSignup
8
8

More than 5 years have passed since last update.

SwiftのSpriteKitの中から別のViewControllerに切り替える方法

Last updated at Posted at 2015-04-06

SpriteKitを使っていて、たとえば設定画面を作る場合通常のUIKitを使うViewControllerに切り替えたい場合があります。
最初に新しいViewControllerを作ります

「New File...」から「source」の「Cocoa Touch Class」を選んでUIViewControllerのサブクラスとなるクラスを作ります。ここでは仮に「SettingsViewController」という名前にします。
SKSeneの中から新しいViewControllerを呼び出します。

たとえばタッチイベントの中で次のようにします。まずViewControllerを作ります。

var mSettings:UIViewController = SettingsViewController()

次にビューコントローラを切り替えます

UIApplication.sharedApplication().keyWindow?.rootViewController = mSettings

これでうまく切り替わると思います。

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8