title: how to access mouse coordinates in android studio
body: <p>I'm new to Android Studio and I am working on my first real game. I'm having trouble with getting and storing mouse coordinates. Basically, whenever the screen is touched, I need to do something based on where it is clicked. Below is my code. </p>
  
  <p>public class NonmultiplierSixGame extends AppCompatActivity {</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(new MyView(this));
  
  }
  
  
  public class MyView extends View implements View.OnTouchListener{
      public MyView(Context context){
          super(context);
      }
  
      @Override
      public boolean onTouch(View MyView, MotionEvent event) {
          Globals.SetSelect(-2);
          float mx = event.getX();
          float my = event.getY();
  
          if (mx &gt; 10 &amp;&amp; my &gt; 10) {
              Globals.SetSelect(1);
          }
          else {
              Globals.SetSelect(0);
          }
          return true;
  
      }
  
      protected void onDraw(Canvas canvas) {
          super.onDraw(canvas);
          //I have a bunch of shapes and text here
          }
      }
  </code></pre>
  
  <p>select is a public static int being stored in a <code>Globals.java</code> file and is initially set to -1. When I run the code, the value of select is not changed when I click anywhere.
   I tried to search for an answer but I couldn't find anything, so I decided to get a stack overflow account and ask a question :)</p>