Реализация события движения: невозможно обнаружить еще одно последовательное касание.Android

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 Реализация события движения: невозможно обнаружить еще одно последовательное касание.

Сообщение Anonymous »


This is my Thumb Wrestling Game:

I have four states for my game: 00, 01, 10,11

00 if none is pressed. 10 if left is pressed but right is not. 01 if right is pressed but left is not. 11 if both are pressed and call the take damage function.

My problem is that:

Why does my state won't go to 11
Изображение
How to fix this? Please help me.
var touchState by remember { mutableStateOf("00") } // "00", "10", "01", "11" var firstTouch by remember { mutableStateOf("") } // "", "P1", "P2" // Assuming this is the "STATE OF THE HAND BY DRAWABLES" Row Row( modifier = Modifier .fillMaxWidth() .background(color = Color.Gray) .weight(1.4f) // Adjust the weight as needed ) { // Player 1 control area Box( modifier = Modifier .weight(1f) .fillMaxHeight() .background(Color.DarkGray) .pointerInteropFilter { motionEvent -> when (motionEvent.action) { MotionEvent.ACTION_DOWN -> { if (touchState == "00") { touchState = "10" } if (touchState == "01") { touchState = "11" //CALL DAMAGE FUNCTION Log.d("damage", "damage applied to player 2") } if (firstTouch == "") firstTouch = "P1" Log.d("test",touchState) } MotionEvent.ACTION_UP -> { if (touchState == "10") { touchState = "00" } if (firstTouch == "P1") { firstTouch = "" } Log.d("test",touchState) } } true } ) // Player 2 control area Box( modifier = Modifier .weight(1f) .fillMaxHeight() .background(Color.LightGray) .pointerInteropFilter { motionEvent -> when (motionEvent.action) { MotionEvent.ACTION_DOWN -> { if (touchState == "00") { touchState = "01" } if (touchState == "10") { touchState = "11" //CALL DAMAGE FUNCTION Log.d("damage", "damage applied to player 1") } if (firstTouch == "") firstTouch = "P2" Log.d("test",touchState) } MotionEvent.ACTION_UP -> { Log.d("test",touchState) if (touchState == "01") { touchState = "00" } if (firstTouch == "P2") { firstTouch = "" } Log.d("test",touchState) } } true } ) } // Debug Text - Displaying the current touch state and first touch Text("Touch State: $touchState, First Touch: $firstTouch") }

Источник: https://stackoverflow.com/questions/780 ... tial-touch
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Android»