03-05-2011 09:15 PM
In an app that I'm creating, comonents of it (which are sprites) need to be moved around, connected, and disconnected by the user. Right now, I use Mouse_Down, Mouse_Move and Mouse_Up for the movement, and I have set up a double-click to work with the connecting. I need another gesture/whatever for the user to do for disconnecting. I don't want to add a button to switch between connecting and disconnecting, since I'd like them to be able to do both on the fly.
Any suggestions for the type of event I should hook the disconnecting up to?
Solved! Go to Solution.
03-05-2011 09:23 PM - edited 03-05-2011 09:25 PM
If you don't have to have the project done before you get a device in hand then perhaps a two finger spreading gesture would be a good "disconnect" gesture. (Simulator doesn't support multitouch but the AIR API's do.)
Edit: This would involve some 2d geometry computation, but another possibility might be to detect a single finger swipe gesture that is intended to cut an imaginary connection between the two sprites (assuming of course that their geometries are such that a "cut" swipe gesture would seem intuitive).
03-05-2011 11:12 PM
I forgot to mention, when the device is released I plan to use a two-finger thing to resize the sprites. I like the idea of "cutting" the connection though. I was thinking of something like this too, (after playing fruit ninja on my friends ipod), but I'm not exactly sure how to go about this sort of thing. Would it require touch events or anything that is not testable in the simulator?
03-06-2011 01:39 AM
For now to be safe you could probably do something like this to avoid depending on any gesture API stuff:
On a mouse down set a state variable and save the mouse down coordinates. On a mouse up get the coordinates for the mouse up, and compute the line segment from the mouse down location to the mouse up location. Then compute whether that line segment crosses a line segment representing a connection between your two connected sprites.
Just thinkin' out loud.