i recently started porting our app to android tablet and i have some problems with touches.
basically we have camera that rotates around object, left click for selecting objects, and multitouch for zooming.
it is easy to identify one from two touches, but how to register that i, for example, started rotating camera and i do not want any selection? i hope i am clear enough.
currently now if i am rotating camera, if any object is below my finger it gets selected, this is not what i want. it was easier to solve this problem with mouse clicks.
any help appreciated.
[EDIT] here is the code i have so far:
Here, I wrote this in C#, so you'll probably have to convert it to JS if you want to keep your code the same:
A few notes to what I did here: I created an enumeration that defines what "Mode" the game is in. This way, we kinda lock ourselves into the state that the user starts in, and stay there until they take their fingers off of the screen. (Which seems to be what you want)
What this does is it originally sets the game in "MoveMode.None". If you put down two fingers within 1 second, you're set to "Zoom" until you let go of the screen. If you put down one finger and hold it for a second, you're in "Rotate" until you let go of the screen. You can increase or decrease this buffer by changing the constant "touchTimeBuffer" to whatever value in seconds that you want.
While this is what you asked for, you might want to rethink the usage, if you look at other apps (look at google maps, for instance) they will automatically switch from pan to zooming, no matter if you "meant to" or not. I also disregarded if both touchphases are "Moved", because some people pinch by putting one finger down, and moving only one of them.
Good luck, hope this helps!
Maybe I'm missing something, but it sounds like you simply want to ignore your "select object" code whenever any of the touches are moving.
Here is one way to do that:
answered Sep 09 '11 at 11:02 PM