- Home /
How to manage different touch Pads
Hi,
I'm failing to achieve a simple solution for this problem. I've recently posted this question, but it sounded really confusing, so I'm getting back with some more objective information. I'm in a dead end for weeks now.
Having the screen divided in two areas (touchZones), and then, logging touches per starting point (if the touch started on the left or right area, independently from where it ended). My limited programing experience isn't helping much. I would love if one of you could shade some light on this matter.
Here is a simple picture that describes what I'm trying to achieve:
Touches starting on Pad A will be computed as "A" while touches starting at B, will be computed as "B". In the end, this is about having the right side of the screen (B) dedicated to touch swipes, while keeping the left area (A) for a dynamically spawning JoyPad.
As of now, my code goes like this (but it isn't working as intended... touches are getting mixed when ending/canceled). The "getTouchOutput" is running at Update.
function getTouchOutput () {
var i : int = 0;
var count : int = Input.touchCount;
if (count > 0) {
if (!touchStartSet[i]) {
while(i < count) {
touch[i] = Input.GetTouch(i);
touchFinger[i] = touch[i].fingerId;
touchStart[i] = touchCurrent[i] = touch[i].position;
touchStartSet[i] = true;
if (touchZone.Contains(touchStart[i])) touchPad[i] = true;
else touchPad[i] = false;
i++;
}
}
else {
while(i < count) {
if (touchPad[i]) touchDraw(touchPrevious[i], touchCurrent[i]);
else joyDraw(touch[i].position, touchStart[i]);
touchPrevious[i] = touchCurrent[i];
if (touch[i].position != touchPrevious[i]) touchCurrent[i] = touch[i].position;
touchOutput[i] = setTouchMotion(touchPrevious[i], touchCurrent[i]);
if (touch[i].phase == TouchPhase.Ended || touch[i].phase == TouchPhase.Canceled )
resetTouch(i);
touch[i] = Input.GetTouch(i);
i++;
}
}
}
}