<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi KK Subbu,<br>
<br>
I own that book and luckily I red already that chapter. Anyhow it
was a good recommendation;) <br>
<br>
I am aware of the `step` method, that is not really what I want in
this case. I am preparing a video tutorial, I need changes to be
slow and the user to be able to modify stuff. Something feeling like
Etoys, but in Smalltalk. <br>
<br>
I discovered by accident that what i wanted is not difficult to
achieve running this:<br>
----------- for some reason it works -------------------<br>
1 to: 10 do: [:x |<br>
e forward: 10.<br>
Transcript show: ('[{1} -- hello]' format: {x}); cr.<br>
(Delay forMilliseconds: 500) wait.<br>
]. <br>
--------------------------------------------------------<br>
<br>
Then after your suggestion I went to review that chapter in search
for inspirations. And I remembered the `World` is just a
`PasteUpMorph`, so I started to dig into the class and I found this
method which I already read about somewhere else, probably "the
white book": `doOneCycleNow`<br>
-------- working, reasonable, easy to read --------------<br>
1 to: 20 do: [:x |<br>
e forward: 10.<br>
World doOneCycleNow.<br>
(Delay forMilliseconds: 200) wait.<br>
]. <br>
---------------------------------------------------------<br>
<br>
<br>
Then I wrote this, but i don't think i will use it because it starts
to be difficult to understand for new users. <br>
----- better looping to not starve UI --------------<br>
[1 to: 10 do: [:x |<br>
e forward: 10.<br>
World doOneCycleNow.<br>
(Delay forMilliseconds: 500) wait.<br>
] ] fork. <br>
-----------------------------------------------------<br>
<br>
<br>
If you have other recommendations for improvement let me know.<br>
<br>
bye<br>
Nicola<br>
<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 10/23/19 10:46 PM, K K Subbu wrote:<br>
</div>
<blockquote type="cite"
cite="mid:dfee5ae9-60a4-ed2d-d177-8dd8c832ee6c@gmail.com">Nicola,
<br>
<br>
Morphic updates to Display are buffered, so you can't animate them
through delays. Morphic core already has built-in facilities to
support animation in an efficient way. There is an excellent
tutorial by John Maloney at:
<br>
<br>
<br>
<a class="moz-txt-link-freetext" href="http://sdmeta.gforge.inria.fr/FreeBooks/CollectiveNBlueBook/morphic.final.pdf">http://sdmeta.gforge.inria.fr/FreeBooks/CollectiveNBlueBook/morphic.final.pdf</a>
<br>
<br>
See the section on "Adding Liveness" (page 11) for the specifics.
<br>
<br>
HTH .. Subbu
<br>
<br>
On 24/10/19 5:03 AM, Nicola Mingotti wrote:
<br>
<blockquote type="cite">Hi,
<br>
<br>
I would like a Morph to move and then wait a bit, move and wait
a bit ... and so on. I can't get it.
<br>
<br>
For example, this code works as expected:
<br>
------------
<br>
1 to: 10 do: [:x |
<br>
Transcript show: ('[{1} -- hello]' format: {x}); cr.
<br>
(Delay forMilliseconds: 500) wait.
<br>
].
<br>
--------------
<br>
<br>
But once i try to put the Delay between a Morph changes it does
not do what i want. That is, the morph does all the actions
together at the end of the loop.
<br>
<br>
---------------------------
<br>
e := PolygonMorph new.
<br>
e openInWorld.
<br>
e position: 300@300.
<br>
e heading.
<br>
e forward: 50.
<br>
<br>
1 to: 10 do: [:x |
<br>
e forward: 10.
<br>
(Delay forMilliseconds: 500) wait.
<br>
].
<br>
---------------------
<br>
<br>
bye
<br>
Nicola
<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________
<br>
Beginners mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.squeakfoundation.org/mailman/listinfo/beginners">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>