Timing animation in a script?

David McFarlane mcfarla9 at msu.edu
Thu Jul 9 20:50:34 UTC 2009


I know this got answered well enough already, but 
I wanted to build on Michiel's answer and add 
that to the record.  I have done animation like 
this without any Do... While loop at all, just 
using a List object to do the looping.  I set the 
List selection to Sequential, Exit List After, 
e.g., 60 seconds (must use seconds here, not ms), 
and have a single row (level) with my 
Procedure.  Now the List will take care of all the timing.

Then in the list procedure I could put inline script as above, e.g.,

myDisplay.x = myDisplay.x + 1
myDisplay.y = myDisplay.y + 1
myDisplay.run

Alternatively, I could put a display object 
(myDisplay in our example) directly into the 
procedure right after the script, and set its 
Duration to 0 (so that the loop simply runs as 
fast as it can).  Now the display object shows up 
directly in the structure instead of staying 
hidden in the script, and the script simplifies to

myDisplay.x = myDisplay.x + 1
myDisplay.y = myDisplay.y + 1

This is actually rather clean and elegant, 
although I rather prefer not to manipulate 
properties directly in script and instead use 
attribute references.  So, I could use attribute 
references in the Postition X and Y properties of 
the display object or sub-object, e.g., [myX] and 
[myY].  I might also create global variables in 
the User Area to hold values for myX and myY 
between loop iterations, and as before advance 
the position in script before the display object, 
and my script might come out like

myX = myX + 1
myY = myY + 1
c.SetAttrib "myX", myX
c.SetAttrib "myY", myY

(Note that although the variables myX and myY 
have the same names as the context attributes 
"myX" and "myY", these are all distinct objects!)

Admittedly this may seem more troublesome than 
using the direct property manipulation as above, 
so you have to use your judgment according to the 
particular circumstances.  And of course, some 
time before my List I would have to initialize 
myX and myY, but you would have to do that for any of these approaches.

One final issue on using a List to do the loop 
instead of Do... While -- by default the List 
will create a line in the .edat log for every 
loop, which could get messy.  You could prevent 
that by opening up the Properties dialog for the 
list procedure (Edit > Properties... after 
selecting the procedure, or right-click anywhere 
in the procedure window) and then unchecking Log 
Data.  Admittedly this is a very obscure feature 
and will likely confound anyone who later works 
with your program, so perhaps that is reason 
enough to stick with the Do... While approach.

-- David McFarlane, Professional Faultfinder


At 6/25/2009 03:58 PM Thursday, you wrote:

>Thanks for responding, I wound up doing something like what you
>suggested.
>
>Cindy
>
>On Jun 4, 11:05 am, Michiel Spape <Michiel.Sp... at nottingham.ac.uk>
>wrote:
> > Hi,
> > What do you mean by 'show animation I created 
> in..'? Are you trying to show an avi file, for 
> example, or alternatively, move a picture 
> across the screen in 600 ms (say, 1 pixel each 
> 20 ms)? For the latter, I typically set start 
> and end points, and check every time whether 
> the 600 ms have passed. If one would, for 
> example, have an imagedisplay, myDisplay, 
> showing a picture at x,y = 300,400, then moving it, this would be possible:
> >
> > Dim starttime as long
> > Starttime = clock.read
> > While (clock.read - starttime) < 600 do
> >         myDisplay.x = myDisplay.x + 1
> >         myDisplay.y = myDisplay.y + 1
> >         myDisplay.run
> > Wend
> >
> > With the image being in the unreferenced 
> objects ('deleted', which makes a mess of your 
> experiment, but using goto loops isn't that transparent either).
> >
> > For the former, I do not see why one would 
> want to use a while...loop. Isn't the 
> duration/offset enough to time it properly 
> (though i have never used avi files, I wouldn't 
> be surprised if this would be the case)
> >
> > Best,
> > Michiel
> >
> > Michiel Spapé
> > Research Fellow
> > Perception & Action group
> > University of Nottingham
> > School of Psychology
> >
> > -----Original Message-----
> > From: e-prime at googlegroups.com 
> [mailto:e-prime at googlegroups.com] On Behalf Of javagirl
> > Sent: 03 June 2009 16:23
> > To: E-Prime
> > Subject: Timing animation in a script?
> >
> > Hi
> >
> > I would like to show animation I created in a Do..While loop for about
> > 600 ms.  Does anyone know the best way to do this?
> >
> > Thanks
> >
> > Cindy


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en
-~----------~----~----~----~------~----~------~--~---



More information about the Eprime mailing list