I’m using some rect contains touch controls as shown here:
speed = 0;
if (accelButton.Contains(touchPos)){
speed = 1;
}
But when I take my finger off the rect area the speed continues to = 1. If I set speed to 0 at the begin of the update there is no difference. What is the best way to reset this value back to 0 once the user removes their finger from the device?
thanks.
I was able to reset the value back to 0 when no buttons are pressed by adding a touchCount command. This creates a problem when 2 or more buttons are pressed however because the count is not zero.
var count = iPhoneInput.touchCount;
if (count = 0){
speed = 0;
}
Do I have to start assigning IDs to each finger to get the speed to reset while another button is being pressed at the same time? Thanks.
The issue is that all buttons return a value of “true” if only one button is still pressed. For example, if you press button (1) and then button (2), then lift from button (1), button (1) is still “true” because the total count still does not equal 0. I need a way to constantly update which buttons are being touched each frame and reset the ones that are no longer being touched.