對于我正在創建的游戲,當按下開始按鈕時,我在開始時有一些影片。但是,能夠觸摸螢屏會干擾此影片。有什么辦法可以讓用戶在點擊開始按鈕后(比如 10 秒)才能與螢屏互動?這是我當前用戶觸摸的代碼:
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
let location = touch.location(in: self)
player.position.x = location.x
player.position.y = -300//location.y
}
}
uj5u.com熱心網友回復:
在整個螢屏中停止 ClickEvent。
view.isUserInteractionEnabled = false
一段時間后繼續 ClickEvent,即:10 秒。
DispatchQueue.main.asyncAfter(deadline: .now() 10) {
self.view.isUserInteractionEnabled = true
}
uj5u.com熱心網友回復:
您可以在單擊螢屏時禁用用戶互動,并在 10 秒后啟用它作為-
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
let location = touch.location(in: self)
player.position.x = location.x
player.position.y = -300//location.y
}
self.view.isUserInteractionEnabled = false
DispatchQueue.main.asyncAfter(deadline: .now() 10) {
self.isUserInteractionEnabled = true
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/339846.html
