Loading images via swipe...

I have a 16 frame sprite animation of earth that I would like to rotate via dragging to simulate a 3D object. I would like the sprite’s x position to remain stationary as you drag your finger over it.

Any ideas to get me started?

Thanks,

GP [import]uid: 2108 topic_id: 17636 reply_id: 317636[/import]

so if the user drags form right to left, you want the earth to spin right to left and if the user swipes from left to right the earth spin left to right?

i would not use sprites

i would use for loops

c [import]uid: 24 topic_id: 17636 reply_id: 67103[/import]

Thanks for the response Carlos… on a Friday night no less!

Yes, swipe right to spin right and swipe left to spin left.

I currently have the globe sprite working with the slider widget, but thought a “swipe to spin” would feel more natural.

In lieu of a sprite you say you would use a for loop. Could you please elaborate… movie clip, individual images in a table, etc.?

Thanks Again,

GP
[import]uid: 2108 topic_id: 17636 reply_id: 67108[/import]

break the sprite into images 1 to 16 - (send them to me) no promises i get something out but maybe done this million times —

just loop the images instead of a sprite so you can do the current.x less than prev.x then loop backwards… if the other way loop fwd.

c
[import]uid: 24 topic_id: 17636 reply_id: 67119[/import]

here is my simple sample 4 u, may be will be useful

http://www.mediafire.com/?qqpp2o2mz1q1251,v1ma516mm1cmmjx,ew2gcxwcd245yu3,pb4fo66hld8yih4,s4ug1xahp88hs7a,hbdd18ktdde7pid,2aw7yf4vt8oz9nn,ck9vvbfsxx9xitj [import]uid: 65903 topic_id: 17636 reply_id: 67129[/import]

@aabweber
Thanks for the cool sample. It’s not exactly the look and feel I was after, however, it will be great for a future project I have in mind. [import]uid: 2108 topic_id: 17636 reply_id: 68248[/import]

will do later - can you zip it and post the zip in a place easy to download [import]uid: 24 topic_id: 17636 reply_id: 68253[/import]

http://db.tt/TjF1LSj6

Thanks! [import]uid: 2108 topic_id: 17636 reply_id: 68255[/import]

Carlos, et al:

I added some display text to report back position values and it appears the problem is related to the conditional under the moved phase. Basically, if you start a swipe, don’t let go, then reverse direction, the images loading will not reverse until your swipe crosses back over the original swipe touch.

I’m guessing I need to do something with the difference in values between the start and stop swipe positions, but I can’t seem to figure it out. I’ve tried with caffeine and without… perhaps alcohol next.

Also, any idea how to slow down the rate of images being displayed?

Here it the new code download: http://db.tt/TjF1LSj6

Thx,

GP [import]uid: 2108 topic_id: 17636 reply_id: 68894[/import]

@Carlos
I took the hints you suggested, searched the forums, then did some serious trial and error. End result… 98% success. Could you please review my code and assist with the following questions?

  1. Changing the direction of a swipe, without letting your finger up first, does not reverse image direction as expected… it appears to wait until your finger goes back beyond the original touch position. Direction will change as expected if you start a new swipe. I’m guessing the glitch is with the conditional under the moved phase… maybe I need to somehow add back the difference between swipeStart and swipeStop. Any thoughts?

  2. Touching a transparent section of an image (near an edge) will trigger a swipe. Is this because an event listener is still assigned to the hidden images? I tried to remove these event listeners before the conditional, then adding them back when complete (under the move phase), but this change would cause the simulator to repeatedly crash after swiping back and forth several times. Does it matter much, performance wise, that each listener is not being removed at the time its respective image is being hidden? Do I need to assign the focus differently to the current image?

  3. Is a focus assignment needed if the current image will be the only item that is being swiped… there will eventually be some buttons on the stage as well.

  4. Is there a difference, performance wise, between .isVisible = false and .alpha = 0?

  5. Is an end phase needed if no action is required to happen during this time?

  6. Is there a quick explanation regarding your advice on loading multiple images vs. a single, albeit larger, sprite? Why is this advantageous in my scenario?

Thanks so much for your help!

GP

Here are the files and code (iPad): http://db.tt/TjF1LSj6 [import]uid: 2108 topic_id: 17636 reply_id: 68251[/import]

Hi Carlos,

A few weeks ago, you said you’d take a look at my code, but I never heard back. Did you ever get a chance?

I was able to get much closer to a solution by adding adding the swipeDiff into the conditional…

if swipeStart + swipeDiff \< swipeStop then  
 -- loop images forward  
elseif swipeStart + swipeDiff \> swipeStop then  
 -- loop images backwards  
end  

There is still a slight lag when reversing the swipe… watch the screen text as you slowly reverse swipe direction (without letting go).

You can download the updated code (for iPad) @ http://db.tt/mKrKf46M

Thank you so much,

GP [import]uid: 2108 topic_id: 17636 reply_id: 72556[/import]