因此從watchOS 3.0開始,您現在可以獲得數字皇冠的旋轉。我設法在InterfaceController中使用crownDidRotate函數。 但是我無法從SKScene類中獲得皇冠的旋轉。 有人可以幫助我,我現在很迷路嗎? 謝謝。watchOS 3.0在SpriteKit中檢測皇冠旋轉
4
A
回答
7
爲了讓您的接口控制器的crownDidRotate
電話,你不得不採用WKCrownDelegate
協議在接口控制器,並設置接口控制器爲crownSequencer
的delegate
。
要獲得crownDidRotate
呼叫在其它的類,採用該類中WKCrownDelegate
協議,並設置類的實例作爲的delegate
你的接口控制器的crownSequencer
。
想必你已經有一些這樣的代碼來設置SpriteKit場景:
class InterfaceController: WKInterfaceController {
@IBOutlet var spriteGizmo: WKInterfaceSKScene!
override func awake(withContext context: AnyObject?) {
super.awake(withContext: context)
let scene = MyScene(fileNamed: "MyScene")
spriteGizmo.presentScene(MyScene(fileNamed: "MyScene"))
}
}
如果你已經聲明WKCrownDelegate
符合您的MyScene
類,只需添加一條線,將其設置爲的委託接口控制器的冠序:
let scene = MyScene(fileNamed: "MyScene")
spriteGizmo.presentScene(MyScene(fileNamed: "MyScene"))
crownSequencer.delegate = scene
(或者,你可以通過設置在故事板的WKInterfaceSKScene
的場景在這種情況下,你仍然可以從你的接口引用WKInterfaceSKScene
。控制器與IBOutlet
。然後在awake(withContext:)
,您可以通過該出口進入現場,並設置爲冠代表)
0
在watchOS 3只是任何物體對象可以將其設定爲一個代表獲得數字樹冠事件:
let crownSequencer = WKExtension.shared().rootInterfaceController!.crownSequencer
crownSequencer.delegate = self
crownSequencer.focus()
然後通過實現回讀值:
func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double)
重要的是要調用focus()
,特別是對控制器,其UI適應屏幕,不需要實際的滾動。
相關問題
- 1. 數字皇冠旋轉的增量/減量值
- 2. 檢測iPhone旋轉旋轉?
- 3. 監測數碼皇冠的價值? (Watch OS 2)
- 4. SpriteKit GameScene旋轉問題
- 5. 在3d中檢測對象的旋轉
- 6. 旋轉臉部檢測
- 7. 當iphone旋轉時檢測
- 8. 碰撞檢測在旋轉矩形
- 9. 如何使用旋轉檢測在opensmile
- 10. 在國王跳棋上繪製皇冠形象?
- 11. graphviz中的皇冠圖 - 如何正確保存訂單?
- 12. Android 3.0操作欄旋轉
- 13. 檢測碰撞SpriteKit Swift
- 14. SpriteKit。停止與CameraNode旋轉紋理
- 15. SpriteKit使用applyImpulse移動旋轉physicsBody
- 16. 在Swift 3.0中設置界限SpriteKit
- 17. 在SpriteKit旋轉座標系統中的視場中
- 18. 在numpy數組中檢測樹的高度和樹冠寬度
- 19. 如何使SpriteNode在SpriteKit中與Swift一起旋轉?
- 20. 在SpriteKit中使用touchesMoved旋轉獎金輪
- 21. 檢測Microsoft Surface上的相機旋轉?
- 22. React原生檢測屏幕旋轉
- 23. didAnimateRoation toInterfaceorientation - 檢測何時完成旋轉?
- 24. 旋轉圖像上的碰撞檢測
- 25. 碰撞檢測旋轉立方體
- 26. cocos2d旋轉精靈碰撞檢測
- 27. 檢測顯示器是否旋轉
- 28. 檢測子視圖的旋轉
- 29. 帶旋轉矩形的碰撞檢測
- 30. 檢測旋轉(方向更改)破壞