-
Notifications
You must be signed in to change notification settings - Fork 0
GameWidget のシンプルな例
RedRimmedBox edited this page Apr 18, 2023
·
1 revision
import SpriteKit
import GameWidget
class Scene: SKScene, ButtonResponder {
let buttonSystem = ButtonNotificationCenter()
override func didMove(to view: SKView) {
// ボタンからの入力を受け取れるように登録します.
self.registerTo(self.buttonSystem)
// システムを有効化します.
// システムに登録されたすべてのオブザーバがボタンに反応するようになります.
self.buttonSystem.activate()
}
func touchDownButton(notification: Notification) {
// your implementation
print(self.getButtonEvent(notification)) // get button event
}
func touchUpButton(notification: Notification) {
// your implementation
}
}
// Scene: SKScene
override func didMove(to view: SKView) {
// ....
let buttonNode = Button("Sample").node()
self.addChild(buttonNode)
}
画面の中央にボタンができたら成功です!