Android multi-touch. How exactly does it work

for that.
3) Loop through all the other indeces using getX(index) and getY(index)

Note: the index of each pointer is not kept constant, so the first finger you put down will not always be index 0, and the third finger to touch the screen won't always be index 2. If you need consistency by finger, then you need to use the pointer id to get the index that you care about.
I think you should disabuse yourself of the notion of a 'primary' finger. The ACTION_DOWN is performed the first time a finger touches the screen (call it A). Then ACTION_POINTER_DOWN if a second finger touches (call it B). If the user releases finger A, then the ACTION_POINTER_UP is sent, because there is still one remaining finger left. And the ACTION_UP is sent when finger B is removed. The ACTION_DOWN and ACTION_UP are used to signify the first finger and last finger, which may not be the same finger. So there is no such thing as a 'primary' finger. so this is probably more than you need and may not fit into exactly what you are doing. But I was hacking around since the post were you said you weren't using buttons, and I thought 'if this were me, I would have my own class to help encapsulate the 'button' concept, even if it is not the Android Button.' So I made this:
view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
public class Button  
{  
    private int top, left, width, height;  
      
    private int timesPressed;  
      
    public Button(int postionTop, int positionLeft, int sizeWidth, int sizeHeight)  
    {  
        //... fill fields  
    }  
      
    public boolean isEventInbounds(int x, int y)  
    {  
        return /* determine inside bounds */;  
    }  
      
    public void setPressed(boolean pressed)  
    {  
        if (pressed)  
        {  
            timesPressed += 1;  
        }  
        else 
        {  
            if (timesPressed > 0)  
            {  
    &n

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

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