Android multi-touch. How exactly does it work

*/); 
Button left;
Button right;

        Button left = new Button(/* get bounds */);
        Button right = new Button(/* get bounds */);
 

Then I did some other modifications of my original code:
1) I added a Map to track the Pointer IDs and what button they were last pushing
2) some methods for encapsulating the effects of left/right buttons
3) the OnTouch() method which determines what to do.

For #1, and #2, and #3 before adding the MOVE action, I had this code:
view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
Map<Integer, Button> knownPointerMap = new HashMap<Integer, Button>();  
 
    private void goLeft()  
    {  
        renderer.setSpriteState('r', false);  
        renderer.setSpriteState('l', true);  
    }  
      
    private void goRight()  
    {  
        renderer.setSpriteState('r', true);  
        renderer.setSpriteState('l', false);  
    }  
      
    private void stopLeft()  
    {  
        renderer.setSpriteState('l', false);  
          
        if (shouldGoRight()  
        {  
            goRight();  
        }  
    }  
      
    private void stopRight()  
    {  
        renderer.setSpriteState('r', false);  
          
        if (shouldGoLeft()  
        {  
            goLeft();  
        }  
    }  
      
    private boolean shouldGoLeft()  
    {  
        return left.isPressed();  
&nbs

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

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