user1475782
user1475782

Reputation: 11

Can I disable multitouch for a Windows Phone Application?

I'm currently working on a game for Windows Phone 7, using the XNA version of Cocos2d. Due to the rules of the game, I need it so that the user can only touch one thing at a time but multitouch seems to be always in effect. Additionally I don't know if this is a Cocos error, but it also causes the game to behave erratically (responding to a single touch like they were many).

I guess I would have to correct every touch event of the game one by one, but I was wondering if I can use something to disable multitouch quickly, or reduce the number of touches accepted to one at a time.

Upvotes: 1

Views: 376

Answers (3)

Jacob Anderson
Jacob Anderson

Reputation: 26

Yes, you can do this with Cocos2D-XNA. You set the TouchMode to be either OneByOne, or AllAtOnce. OneByOne will give you the single CCTouch signature methods, and AllAtOnce will get you the List signature methods.

public MyCtor() {
  TouchEnabled = true;
  TouchMode = CCTouchMode.OneByOne;
}

public override bool TouchBegan(CCTouch t) {
}

public override void TouchMoved(CCTouch t) {
}

public override void TouchEnded(CCTouch t) {
}

Now you only get one touch at a time. There's no way to disable the touch pad's delivery of all touches from all fingers though. As another user mentioned, you would just ignore those.

Remember that you get a touch ID with every touch, which works to match the touch data with each began, moved, ended event call. I suggest you make use of touch ID as well to ensure that you are processing only the touches that you want.

Upvotes: 0

Elideb
Elideb

Reputation: 11990

Each frame you can get the list of touches. Since their management is delegated to your code, just ignore them if you have more than one. Another option is only using the first one, remember its TouchID and ignore all the rest. I've used the first option when porting mouse applications over to the phone.

Cocos touch input has to be treated somewhere in the game, in accessible code, so you should have access to their point of entry.

Upvotes: 0

Andrew Russell
Andrew Russell

Reputation: 27215

I'm not sure about Cocos2d-x for XNA. But in regular XNA if you want to force only single-touch input, the simplest way to that is by using the Mouse class. In a touch environment it is still available - emulated by using touches. It only responds to a single touch at a time.

Upvotes: 1

Related Questions