I got a problem with my touchlistener and actually dont get it work correctly.
@Override
public boolean onTouchEvent(MotionEvent event) {
touchControll.processTouchEvent(event); //should do everything!
invalidate();
return true;
}
The Methode processTouchevent simply take the event watch where it was and handles it.
So if the touch was inside of the Joypad it handles the joypad “actions”. But if i want to handle a hitButton event now it dont react.
Example
public void processHitButtonTouch(MotionEvent event){
int touchPosX = (int) event.getX();
int touchPosY = (int) event.getY();
if(event.getAction() == MotionEvent.ACTION_DOWN)
if(touchPosX > Config.BLOCKSIZE*37 && touchPosY > Config.BLOCKSIZE*3 && touchPosY < Config.BLOCKSIZE*7){
this.hitButton.buttonStatus = Pressed.PRESSED;
}
}
on every MotionEvent.ACTION_UP i resett the whole stuff like this:
if(event.getAction() == MotionEvent.ACTION_UP){
joyPad.status = Status.IDLE;
charac.setStatus(Status.IDLE);
this.hitButton.buttonStatus = Pressed.UNPRESSED;
}
I tied if it actually handles more than 1 event with the Loggincat and it does (2 touch 2 times downevent logged!). But it simply dont work like i did it here.
What have i done wrong?!
Thanks alot for the help!
The touch events are caught by only one view in Android, so it’s normal if your hitButton doesn’t react while you keep your finger on the Joypad.
To use multitouch, you have to implement a global view with all your buttons inside (joypad, hitbutton …). So this view catch the event and pass it on the joypad’s touchEventListener or the hitButton’s listener.
Edit : Here an exemple with 2 joysticks
http://code.google.com/p/mobile-anarchy-widgets/source/browse/trunk/Widgets/src/com/MobileAnarchy/Android/Widgets/Joystick/DualJoystickView.java?r=30
Edit2 : a good tutorial
http://android-developers.blogspot.fr/2010/06/making-sense-of-multitouch.html