I made a game using SwiftUI with normal Button
's. I have discovered that my buttons regularly drop inputs, which negatively affects gameplay. I am in the exact situation shown in this link:
As you can see in the comments of this unsolved problem, using touchesBegan with UIKit seems to be the way to get faster, more responsive buttons.
Is there something else I can do using SwiftUI to fix this issue?
I've tried disabling multitouch but to no avail
struct testView: View {
var body: some View {
Text("Press me!")
.onTapGesture{//do nothing}
}
}
If I run this view on an iOS device and press this button fast enough, I get the error: "Failed to receive system gesture state notification before next touch"
I am running XCode 14.0 beta and running this button on an iPhone 11
hacky trick which maybe made button presses slightly faster but did not fix error message
@State var pressed = false
Text("Press Me")
.gesture(DragGesture(minimumDistance: 0, coordinateSpace: .global)
.onChanged { _ in
if !pressed {
// mything
pressed = true
}
}
.onEnded { _ in pressed = false }
)