Re: [Squeakland News] How to do timing in Etoys?
Ricardo Moran <[email protected]> Wed, 10 Sep 2014 17:51:53 -0300
| Newsgroups | gmane.comp.lang.smalltalk.squeak.squeakland |
|---|---|
| Message-ID | <CALr=5n3Ap0ahECXh3y9c4hLUNTUyGUZoo9FTCsyWvcDC9HOOAg@mail.gmail.com> |
Hi Rita, I wrote about this same subject a couple of weeks ago: http://tecnodacta.com.ar/gira/2014/08/physical-etoys-tips-time-handling-part-1/. My approach is a little different, though. I like Etoys ability to represent concepts visually, and I think time is one of those concepts :) The example I chose is about Physical Etoys because I see this question come up very often when programming robots (and also because I had an old video of a simple traffic light built with leds that I wanted to use), but of course it applies to any Etoys project. I'm planning to write a follow up to that article but using the Playfield's timer instead. I think each approach has its own merits so if you don't mind I'll post a link to your blog. Cheers, Richo On Thu, Sep 4, 2014 at 10:32 AM, Rita <ritafreudenberg-gM/[email protected]> wrote: > I just got this question from my students and I thought there might be > others with similar interests. So how can I control sequences of actions > over time? Say, I want to use speech bubbles to tell a story. I have a > number of sentences to show, one after another, and I want to let some time > pass between them to give the reader time to read. How can I do that? > > Well, I can build a timer and check the time to trigger actions when a > certain time is reached. How can I build a timer? > > First of all, you need a variable to count time steps. Open the viewer for > your object. Create a variable by clicking the "v" - symbol in the top row > of the viewer and give your variable a name. I choose "seconds". The > default type is "Number", which is fine and 0 decimals places are perfect > as well. > > > <http://4.bp.blogspot.com/-65hLrEYQmlY/VAhlAMw3YXI/AAAAAAAAARI/5UaG57KrcVc/s1600/Screen%2BShot%2B2014-09-04%2Bat%2B15.08.52.png> > > Now open a new empty script and drag the tiles to assign a new value to > your variable into the script. Change the operation to "increase by" and > the number to "1". Make sure the value of your variable is "0" at the > start! Name the script "timer". > > > <http://1.bp.blogspot.com/-JPEtCg0ct-k/VAhl5Nyo0BI/AAAAAAAAARQ/MmbYIcve0nk/s1600/Screen%2BShot%2B2014-09-04%2Bat%2B15.14.59.png> > > You do know already that the script, once started, will be executed > repeatedly until it is being stopped, right? Do you also know how fast or > how slowly this happens? You can see this when you click on the watch in > the top row of the scriptor and hold the mouse button down. And you can > also change it there! By default, it will be executed 8 times per second. > Change this into once per second! > > > <http://2.bp.blogspot.com/-4ZEeGu9jXAY/VAhm45vstTI/AAAAAAAAARY/9lCanHejHhk/s1600/Screen%2BShot%2B2014-09-04%2Bat%2B15.18.36.png> > > > When you now start the script, each second it will increase the value of > your variable "seconds" by 1! Now you can use the value of the variable in > other scripts: > > > <http://3.bp.blogspot.com/-nnC-9R7XkaA/VAhpZJEVVeI/AAAAAAAAARk/tgnp27YUbBU/s1600/Screen%2BShot%2B2014-09-04%2Bat%2B15.29.50.png> > > Use a all-scripts-tile from the supplies to start both, your script and > the timer, at the same time and watch :) > > *Please note:* It depends on your computer and what other programs are > running on it at the same time, if a second in the Etoys project will be > the same as a second at a real clock. It may not be exactly the same, but > probably close. It is definitely good enough to control the flow of a > story, but for scientific experiments, you should use a real timer! > > You can also find a tutorial to build a timer in project 6 of the book > "Powerful Ideas in the classroom" by Kim Rose and B.J. Allen-Conn. > > > > -- > Von Rita am 9/04/2014 06:32:00 vorm. unter Squeakland News > <http://squeaklandnews.blogspot.com/2014/09/how-to-do-timing-in-etoys.html> > eingestellt > _______________________________________________ > squeakland mailing list > [email protected] > http://lists.squeakland.org/mailman/listinfo/squeakland > > _______________________________________________ squeakland mailing list [email protected] http://lists.squeakland.org/mailman/listinfo/squeakland