修复连击问题

This commit is contained in:
2024-12-24 09:33:21 +08:00
parent b653ee2eee
commit ea2a5642e0

View File

@@ -109,7 +109,8 @@ struct ContentView: View {
runClock() runClock()
} }
func timeOut() { func timeOut(for emoji: [String]) {
guard currentEmoji == emoji else { return }
if gameState == .player1Answering { if gameState == .player1Answering {
player1Score -= 1 player1Score -= 1
} else if gameState == .player2Answering { } else if gameState == .player2Answering {
@@ -121,11 +122,11 @@ struct ContentView: View {
func runClock() { func runClock() {
answerScale = 1 answerScale = 1
let checkEmoji = currentEmoji
withAnimation(.linear(duration: answerTime)) { withAnimation(.linear(duration: answerTime)) {
answerScale = 0 answerScale = 0
} completion: { } completion: {
timeOut() timeOut(for: checkEmoji)
} }
} }