1
所以我正在製作遊戲,並且之前使用左右按鈕來移動。我想改變它到一個自定義類型的滑塊類似於這個http://gyazo.com/05b6079862874a282ad14220e7267bd1我不知道如何讓它更新觸摸開始註冊你滑動你的手指。我到目前爲止是這樣的:Swift-拖動自定義滑塊
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
if self.nodeAtPoint(location) == self.sliderBox{
let move = touch.locationInNode(self)
slider.position.x = move.x
}
}
這得到紅點移動到我摸到哪裏,但我需要能夠有它這樣的,能夠當你按住不放滑動。感謝您花時間看這個。
有一個真棒教程這裏:http://www.raywenderlich.com/76433/how-to-make-a-custom-control- swift – 2014-10-10 05:25:15
謝謝你。我已經能夠通過使用覆蓋func touchesMoved(觸及:NSSet,withEvent事件:UIEvent)來獲得它的工作。 – Alex 2014-10-10 06:49:57