[Newbies] Animation question

obrienj obrienj at protonmail.com
Thu Oct 12 16:24:14 UTC 2017


I am having difficulty getting the following example to work using either delay or step:

aMorph := Morph new.
aMorph position: (100 at 100).
aMorph openInWorld.
30 timesRepeat: [aMorph position: aMorph position +(1 at 0). Transcript show: 'test '; cr.].
(aMorph position) >= (120 at 100) ifTrue: [aMorph color: Color yellow].
Transcript show: 'position: ', aMorph position; cr.

For example:

aMorph := Morph new.
aMorph position: (100 at 100).
aMorph openInWorld.
delay := Delay forMilliseconds: 20.
[30 timesRepeat: [aMorph position: aMorph position +(1 at 0). delay wait.].] fork.
(aMorph position) >= (110 at 100) ifTrue: [aMorph color: Color yellow].
Transcript show: 'position: ', aMorph position; cr.

In the first example the morph moves, changes color, and the Transcript shows its final position. However, in the second example the morph moves but does not change color and the Transcript shows its starting position.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20171012/0e8ee60b/attachment.html>


More information about the Beginners mailing list