i don't want my buttons be pressed at the same time.
if i touch 2 buttons at the same time, it will fire 2 button events, how to avoid this?
how to avoid multitouch on buttons
(5 posts) (3 voices)-
Posted 1 year ago #
-
I'd say you need a ButtonController class that, once a button is pressed, either disables other buttons or that sets a flag so that the other touch handlers can exit early. It would have an array of SPButtons that are "linked" (like radio button groups in other UI packages).
Posted 1 year ago # -
If you don't need multitouch at all in your application, you can simply set the "multipleTouchEnabled" property of your SPView to "NO", e.g. in the application delegate:
mSparrowView.multipleTouchEnabled = NO;Posted 1 year ago # -
Thank you.
the forum is really quick.at present, i use a bool. but i feel the code looks not pretty. and I was thinking maybe there is a function to filter all the button event.
I need multiple touch, is there a way to switch the multipleTouch on/off?
how to get to the mSparrowView from other class? can I set the property outside the delegate?Posted 1 year ago # -
You can reach the sparrowView anywhere via the stage property "nativeView". So, anywhere in your game, you can make a call like this:
SPView *view = (SPView *)self.stage.nativeView; nativeView.multipleTouchEnabled = NO;You just have to take care that the "stage" property of "self" is only available when "self" is already in the display list (when it has a parent that has a parent ... that is connected to the stage). Otherwise, stage will be nil, and nothing will happen.
That will allow you to turn multitouch on an off whenever you like! If that fits your design, that should be the easiest way to do it =)
Posted 1 year ago #
Reply
You must log in to post.