-
swipe gesture help please
I currently have an app that I've made that has a 360 flyaround of an object, to control it I've used a slider. I'd like to change this to simply a swipe gesture, so depending on how the user swipes across the screen, the image will rotate and stop. The image rotating is currently a movie with 80 frames. Can I use a swipe gesture for what I want? Any help, or a link to a similar tutorial would be great.
Thanks Steve
-
You could use MOUSE_MOVE events and simply map the x coordinate of the event to a percentage of the total width, so that it would work exactly like your slider. But it sounds like you want to simulate momentum and friction as well. To do that, you'll need to have a periodic (probably ENTER_FRAME listener) function which manages the rotation of your object based on what you calculate its current momentum to be. The momentum will be based on its rotation speed, which will in turn be based on the speed of the swipe. Each iteration of the rotating function, you'll need to decrease the momentum by some amount, usually by multiplying it by the coefficient of friction, which is a number < 1.
A movie with 80 distinct frames is not a great model, but you can always map the calculated rotation angle to a frame and go to that frame.
-
Cool, thanks for your help, I'll look into that
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|