Android multi-touch. How exactly does it work
}
}
}
public boolean isPressed()
{
return this.timesPressed > 0;
}
}
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)
{
timesPressed -= 1;
}
}
}
public boolean isPressed()
{
return this.timesPressed > 0;
}
}
Now, for this case, I think the only part that is necessary is the fact that there is a public boolean isEventInbounds(int x, int y) method which you can call to check if that button is pressed. I then modified my first bit of code snippet to use this class:
view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
Button left;
Button right;
Button left = new Button(/* get bounds */);
Button right = new Button(/* get bounds
Back [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... Next >>