Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid MultiTouch does not work
    text
    copied!<pre><code> @Override public boolean onTouchEvent(MotionEvent event) { synchronized (getHolder()) { int aktion = event.getAction(); if (aktion == MotionEvent.ACTION_DOWN) { touched = true; bar.shareTouch(event.getX(), event.getY(), touched); } else if (aktion == MotionEvent.ACTION_UP) { touched = false; bar.shareTouch(event.getX(), event.getY(), touched); } if (aktion == MotionEvent.ACTION_POINTER_DOWN) { touched2 = true; bar.shareTouch2(event.getX(), event.getY(), touched2); } else if (aktion == MotionEvent.ACTION_POINTER_UP) { touched2 = false; bar.shareTouch2(event.getX(), event.getY(), touched2); } } return true; } </code></pre> <p>This is a Code to chech if first Finger is going onto the screen or leaving it. The same for another finger.</p> <pre><code>public void shareTouch2(float xTouch2, float yTouch2, boolean touched2) { if (xTouch2 &lt;= gameViewWidth/2) { if (touched2 == true) { touchedLeft2 = true; } else if(touched2 == false) { touchedLeft2 = false; } } else if (xTouch2 &gt; gameViewWidth/2) { if (touched2 == true) { touchedRight2 = true; } else if(touched2 == false) { touchedRight2 = false; } } } </code></pre> <hr> <pre><code>public void shareTouch(float xTouch, float yTouch, boolean touched) { if (xTouch &lt;= gameViewWidth/2) { if (touched == true) { touchedLeft = true; } else if(touched == false) { touchedLeft = false; } } else if (xTouch &gt; gameViewWidth/2) { if (touched == true) { touchedRight = true; } else if(touched == false) { touchedRight = false; } } } private void moveRight() { x += 3; } private void moveLeft() { x -= 3; } </code></pre> <hr> <pre><code>private void checkTouch() { if ((touchedLeft == true &amp;&amp; touchedRight2 == false) || (touchedLeft2 == true &amp;&amp; touchedRight == false)) { moveLeft(); } else if ((touchedLeft == false &amp;&amp; touchedRight2 == true) || (touchedLeft2 == false &amp;&amp; touchedRight == true)) { moveRight(); } else if ((touchedLeft == true &amp;&amp; touchedRight2 == true) || (touchedLeft2 == true &amp;&amp; touchedRight == true)) { } } </code></pre> <p>The <code>checkTouch()</code> is called in the <code>onDraw()</code> Method. Now if I place a finger on the right side of the screen it moves right. Same for left. But if I touch left and the right without removing the left finger the Object still moves left although it should stop. Now when I leave the left finger it still moves left although it should move right.</p> <p>I hope you understand my problem.</p> <p>Hope you can help</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload