EaseInOut using multiple scrolling fields

Create fast, sprite powered games with Animation Engine, co-developed with DerBrill Software!

Moderators: heatherlaine, kevinmiller, robinmiller, malte

EaseInOut using multiple scrolling fields

Postby Dougy » Sun Jan 04, 2015 4:06 am

Hi. I have a problem when using the EaseInOut effect on multiple scrolling fields simultaneously, but with a 500-millisecond delay between each field's scrolling.
The result is that field 1 starts scrolling correctly from the start of its content, but field 2 starts from where field 1 is up to in it's processing (the EaseInOut effect) and then field 3 also starts from where field 1 is up to in its processing (which is nearly at the end of processing). They all finish nearly at the same time. My intention is to create 3 fields which scroll like a slot machine/poker machine with 3 spinning columns (scrolling fields) which start and stop independently (but are actually spinning at the same time - like a poker machine.
On the card I have 2 buttons:
    "Add Content" button which populates the scrolling fields
    "Start" button which has the main processing code

Here is my test code for the EaseInOut of the 3 scrolling fields:
Code: Select all
## "Add content" button on card
## Populate scrolling fields with numbers 1 to 50
on mouseUp
   repeat with x = 1 to 50
      put x into line x of fld "EaseInOut1"
      put x into line x of fld "EaseInOut2"
      put x into line x of fld "EaseInOut3"
   end repeat
end mouseUp


## "Start" button on card
   local lMax1,lMax2, lMax3, lMillisecs
on mouseUp
   put the formattedHeight of fld "easeInOut1" - the height of fld "easeInOut1" into lMax1
   put the formattedHeight of fld "easeInOut2" - the height of fld "easeInOut2" into lMax2
   put the formattedHeight of fld "easeInOut3" - the height of fld "easeInOut3" into lMax3
   disable me
   put the milliseconds into lMillisecs
   send "goEase1" to me in 0 millisecs
   send "goEase2" to me in 500 millisecs
   send "goEase3" to me in 1000 millisecs
end mouseUp

on goEase1
   put the milliseconds-lMillisecs into tCurrentTime1
    set the vScroll of fld "easeInOut1" to round(aeEaseInOut(0,lMax1,2000,tCurrentTime1,3))
   if tCurrentTime1 <= 2000 then
      send goEase1 to me in 20 milliseconds
   else
      enable me
   end if
end goEase1

on goEase2
   put the milliseconds-lMillisecs into tCurrentTime2
   set the vScroll of fld "easeInOut2" to round(aeEaseInOut(0,lMax2,2000,tCurrentTime2,3))
   if tCurrentTime2 <= 2500 then
      send goEase2 to me in 20 milliseconds
   else
      enable me
   end if
end goEase2

on goEase3
   put the milliseconds-lMillisecs into tCurrentTime3
   set the vScroll of fld "easeInOut3" to round(aeEaseInOut(0,lMax3,2000,tCurrentTime3,3))
   if tCurrentTime3 <= 3000 then
      send goEase3 to me in 20 milliseconds
   else
      enable me
   end if
end goEase3


Screenshot of Card attached. Any help much appreciated!
Regards,
Doug.
Attachments
Screen Shot 2015-01-04 at 11.55.50 am.png
LC 6.6.3, AnimationEngine 5.1
BeatSpeak & EVPoint available for iOS devices on the App Store.
Dougy
 
Posts: 15
Joined: Sat Jul 01, 2006 7:37 pm
Location: New Zealand

Re: EaseInOut using multiple scrolling fields

Postby malte » Sun Jan 04, 2015 1:56 pm

Hi Doug,

what you are trying to build is a little different from what you think you are trying to build I guess. If you are looking at a slot machine, it does not just ease in and out. In pseudocode it would look a little like this:


Code: Select all
on startWheel pWheel
  ease in quickly
  roll at constant speed until stop command received
end startWheel

on stopWheel
  ease out quickly
end stop wheel


I currently do not have the time to implement that, however it should be pretty straight forward to do.

Hope that helps,

Malte
malte
 
Posts: 1096
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany

Re: EaseInOut using multiple scrolling fields

Postby Dougy » Sun Jan 04, 2015 2:22 pm

Thanks very much for your prompt reply, Malte. I'll try to implement your pseudocode in the next few days and let you know how it goes. Kind regards, Doug :)
LC 6.6.3, AnimationEngine 5.1
BeatSpeak & EVPoint available for iOS devices on the App Store.
Dougy
 
Posts: 15
Joined: Sat Jul 01, 2006 7:37 pm
Location: New Zealand

Re: EaseInOut using multiple scrolling fields

Postby Dougy » Mon Jan 05, 2015 1:56 pm

Hi Malte (and/or others?).
I've had a think about your reply, Malte, and I may not have been clear on how the 3 wheels/spinners behave: they are initiated by a single "Start" button which spins all 3 wheels concurrently through three different phases: EaseIn (gradual speed up), a constant spin, and an EaseOut (gradual slow down). There is no "Stop Spinning" button - they complete the 3 phases automatically then stop automatically. HOWEVER, I am wanting the start times of each of the 3 wheels to be slightly delayed, i.e. wheel one starts first, then wheel two maybe 500 millesecs later, then wheel three 500 millsecs after wheel two. Sorry if I seem pedantic. Anyway, I'll press on. Thanks for your help :-)
LC 6.6.3, AnimationEngine 5.1
BeatSpeak & EVPoint available for iOS devices on the App Store.
Dougy
 
Posts: 15
Joined: Sat Jul 01, 2006 7:37 pm
Location: New Zealand

Re: EaseInOut using multiple scrolling fields

Postby malte » Mon Jan 05, 2015 5:24 pm

Hi dougy,

no need to apologize for being pedantic :-)

Maybe I was not clear in my reply also. The way I think about it may be a tad bit overcomplicated but the "correct" behaviour of a slot machine:

start getting the wheel to spin at a constant speed using easeIn, scroll constant for a while, then easeOut to come to a halt. This is not what easeInOut does! Even though it might look like it. What you are trying to do will come close, but will not simulate what you are originally after. Once I find the time I will set up the other version. :-)

Here is a corrected version of your script that will get you closer (untested out of the top of my head) Taking the offset for the currentTime for each goEase handler into account. Hope that helps,

Malte

Code: Select all
on mouseUp
   put the formattedHeight of fld "easeInOut1" - the height of fld "easeInOut1" into lMax1
   put the formattedHeight of fld "easeInOut2" - the height of fld "easeInOut2" into lMax2
   put the formattedHeight of fld "easeInOut3" - the height of fld "easeInOut3" into lMax3
   disable me
   put the milliseconds into lMillisecs["1"]
   put lMillisecs["1"] + 500 into lMillisec["2"]
   put lMillisecs["1"] + 1000 into lMillisec["3"]
   send "goEase1" to me in 0 millisecs
   send "goEase2" to me in 500 millisecs
   send "goEase3" to me in 1000 millisecs
end mouseUp

on goEase1
   put the milliseconds-lMillisecs["1"] into tCurrentTime1
    set the vScroll of fld "easeInOut1" to round(aeEaseInOut(0,lMax1,2000,tCurrentTime1,3))
   if tCurrentTime1 <= 2000 then
      send goEase1 to me in 20 milliseconds
   else
      enable me
   end if
end goEase1

on goEase2
   put the milliseconds-lMillisecs["2"] into tCurrentTime2
   set the vScroll of fld "easeInOut2" to round(aeEaseInOut(0,lMax2,2000,tCurrentTime2,3))
   if tCurrentTime2 <= 2000 then
      send goEase2 to me in 20 milliseconds
   else
      enable me
   end if
end goEase2

on goEase3
   put the milliseconds-lMillisecs["3"] into tCurrentTime3
   set the vScroll of fld "easeInOut3" to round(aeEaseInOut(0,lMax3,2000,tCurrentTime3,3))
   if tCurrentTime3 <= 2000 then
      send goEase3 to me in 20 milliseconds
   else
      enable me
   end if
end goEase3
malte
 
Posts: 1096
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany

Re: EaseInOut using multiple scrolling fields

Postby Dougy » Wed Jan 07, 2015 2:33 am

Hi Malte

Excellent! Got it working now :D
Not quite sure what my problem was, however, using an array to store the milliseconds may have helped - it may have been something to do with the way I was using variables or the values I was using in the GoEase handlers. Anyway, it's all working as I wanted - thanks very much.
LC 6.6.3, AnimationEngine 5.1
BeatSpeak & EVPoint available for iOS devices on the App Store.
Dougy
 
Posts: 15
Joined: Sat Jul 01, 2006 7:37 pm
Location: New Zealand

Re: EaseInOut using multiple scrolling fields

Postby Dougy » Thu Jan 22, 2015 12:55 pm

Just an update. I'm using "aeScrollTo" now, which is better as it includes the callback "aeChangeScrollDone" (sent back to the scrolling object) - nice!
Cheers :-)
LC 6.6.3, AnimationEngine 5.1
BeatSpeak & EVPoint available for iOS devices on the App Store.
Dougy
 
Posts: 15
Joined: Sat Jul 01, 2006 7:37 pm
Location: New Zealand


Return to Animation Engine

Who is online

Users browsing this forum: No registered users and 1 guest