1
私はSpriteを使ってゲームを開発しています。私はあなたがそのGameView上のものを変更することができる機能を追加しようとしています。しかし、この機能のボタンは別のViewControllerにあります。コードを別のView Controllerに実装するにはどうしたらいいですか?ViewContollersの間で情報を共有する
これは私がボタンを
for touch: AnyObject in touches {
// Get the location of the touch in this scene
let location = touch.location(in: self)
// Check if the location of the touch is within the button's bounds
if button.contains(location) {
Ghost.texture = SKTexture(imageNamed:"Ghost2")
}
}
を実装したいとここにボタン
@IBAction func button(_ sender: AnyObject) {
} あるコードですが、ボタンがViewController1上にあり、私は変更したいオブジェクトがありますViewController2(GemScene)
NSUserDefault(優先)を使用して情報を共有できます。 –
[View Controller間でのデータ受け渡し]の可能な複製(http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) – nbloqs