Android multi-touch. How exactly does it work

Android multi-touch. How exactly does it work

OK Guys, I was wondering if someone would be kind enough to explain exactly how multi-touch works in Android? I've read various blogs and tuts online (including the official developers guide) but I still can't make head nor tails of it.

If I press the screen with one finger, no problem, I also know how to detect a non-primary finger touching the screen.

But if I have say, 2 fingers on the screen and I remove one of them, how can I determine where the remaining finger is on the screen? This is partly what I don't understand.

Where does event.getPointerCount, event.getActionIndex(); & event.getActionMasked(); come into it?

Here is my code: Please see the MotionEvent.ACTION_POINTER_UP: section, this is the part I don't understand - I need to know where the remaining fingers are.

Would be grateful for any help - thanks!!

Code

view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
  @Override 
        public boolean onTouchEvent(MotionEvent event) {  
              
         int actionMask = event.getActionMasked();  
        int pointerIndex = event.getActionIndex();  
        int pointerCount = event.getPointerCount();  
              
            switch (actionMask){  
              
            case MotionEvent.ACTION_DOWN:  
 
                        //If primary finger presses left button, move sprite left  
                if (event.getX()<=renderer.leftButton("right") && event.getY()>=renderer.leftButton("top")){  
                        renderer.setSpriteState('l', true);  
                        renderer.setSpriteState('r', false);  
                    }  
        

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... Next  >> 

Copyright © 2007-2012 www.chuibin.com Chuibin Copyright