Note that there are some explanatory texts on larger screens.

plurals
  1. POMotionEvent.ACTION_UP is not working
    primarykey
    data
    text
    <p>I have two images which I am using as joysticks. <code>MotionEvent.ACTION_DOWN</code> is working fine and is padding the images in the correct direction. <code>MotionEvent.ACTION_UP</code> is suppose to return the image back to its default position but is not working. Here is my code for the listener:</p> <pre><code>//First joystick listener joystick1.setOnTouchListener(new OnTouchListener(){ public boolean onTouch(View v, MotionEvent event) { Log.d("TouchTest", event.toString()); //Gets the X and Y values of the users touch when the user is touching //the joystick move image X = event.getX(); Y = event.getY(); CY = cursor.getHeight()/2; CX = cursor.getWidth()/2; joystick1Move = true; int action = event.getAction(); switch (action){ case MotionEvent.ACTION_DOWN: Log.d("TouchTest", "Touch down"); //if the user has touched the image and moves finger right left //up and down for the first joystick then move the joystick image if(X&gt;(joystick1width/2)&amp;&amp;X&lt;(v.getWidth())){ //right CX=CX+5; joystick1.setPadding(20, 0, 0, 0); } if(X&lt;(joystick1width/2)){ //left CX=CX-5; joystick1.setPadding(-20, 0, 0, 0); } if(Y&gt;(joystick1height/2)&amp;&amp;Y&lt;(v.getHeight())){ //up CY=CY+5; joystick1.setPadding(0, 0, 0, 20); } if(Y&lt;(joystick1height/2)){ //down CY=CY-5; joystick1.setPadding(0,0, 0, -20); } break; case MotionEvent.ACTION_UP: Log.d("TouchTest", "Touch up"); joystick1.setPadding(0, 0, 0, 0); break; default: Log.d("TouchTest", "Touch up"); joystick1.setPadding(0, 0, 0, 0); } return true; } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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