Android Simple Code About MultiTouch: Would this Work?
I am a newbie at android dev, and i was wondering why the bottom code is
not working? or atleast not on my friends phone (which has multitouch).
Ok some background:
I am actually making a 2D spaceship game, where you control your ship with
one finger while there is a button which you can use your other finger to
press to shoot. So this game requires a maximum of 2 fingers...
However, my freind says that both fingers are not working at once....they
are working seperetly (which means either this code is not working or my
logic code is not working)....
It would be really helpful if you guys told me if there is something wrong
with this code below or not...
Thanks A lot....helping this 15 year old reach android
public boolean onTouch (View v, MotionEvent event)
{
// TODO Auto-generated method stub
if (event.getPointerCount () > 1)
{
x [1] = event.getX (1);
y [1] = event.getY (1);
}
x [0] = event.getX (0);
y [0] = event.getY (0);
if (event.getAction () == MotionEvent.ACTION_DOWN)
{
fingerTouching [0] = true;
}
if (event.getAction () == MotionEvent.ACTION_UP)
{
fingerTouching [0] = false;
}
if (event.getAction () == MotionEvent.ACTION_MOVE)
{
fingerMoving = true;
}
if (event.getAction () == MotionEvent.ACTION_POINTER_DOWN)
{
fingerTouching [1] = true;
}
if (event.getAction () == MotionEvent.ACTION_POINTER_UP)
{
fingerTouching [1] = false;
}
return true;
}
No comments:
Post a Comment