<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:#000000">No, you have to put that test in the step method, because it has to be checked every time the position changes.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:#000000"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:#000000">Or you have to wait until the animation is done before doing the test - it does work in your first example with my "hack". It does not work in the second example because the forked code is executed after that test (plus forking is bad for this anyways).</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:#000000"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:#000000">- Bert -</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 12, 2017 at 7:39 PM, obrienj <span dir="ltr"><<a href="mailto:obrienj@protonmail.com" target="_blank">obrienj@protonmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>The problem is that I want use something like (self position) >= (120@100) ifTrue: [self color: Color yellow] outside of the step method. Even though the morph moves, it's position remains unchanged and the boolean tests false. Hope this makes sense.<br></div><div class="HOEnZb"><div class="h5"><div class="m_-5740672471129903137protonmail_signature_block m_-5740672471129903137protonmail_signature_block-empty"><div class="m_-5740672471129903137protonmail_signature_block-user m_-5740672471129903137protonmail_signature_block-empty"><div><br></div></div><div class="m_-5740672471129903137protonmail_signature_block-proton m_-5740672471129903137protonmail_signature_block-empty"><br></div></div><div><br></div><blockquote class="m_-5740672471129903137protonmail_quote" type="cite"><div>-------- Original Message --------<br></div><div>Subject: Re: [Newbies] Animation question<br></div><div>Local Time: October 12, 2017 10:25 AM<br></div><div>UTC Time: October 12, 2017 5:25 PM<br></div><div>From: <a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a><br></div><div>To: obrienj <<a href="mailto:obrienj@protonmail.com" target="_blank">obrienj@protonmail.com</a>>, A friendly place to get answers to even the most basic questions about Squeak. <<a href="mailto:beginners@lists.squeakfoundation.org" target="_blank">beginners@lists.<wbr>squeakfoundation.org</a>><br></div><div><br></div><div dir="ltr"><div><span class="m_-5740672471129903137colour" style="color:rgb(34,34,34)"><span class="m_-5740672471129903137font" style="font-family:arial,sans-serif">On Thu, Oct 12, 2017 at 6:24 PM, obrienj </span></span><span class="m_-5740672471129903137colour" style="color:rgb(34,34,34)"><span class="m_-5740672471129903137font" style="font-family:arial,sans-serif"><<a href="mailto:obrienj@protonmail.com" target="_blank">obrienj@protonmail.com</a>></span></span><span class="m_-5740672471129903137colour" style="color:rgb(34,34,34)"><span class="m_-5740672471129903137font" style="font-family:arial,sans-serif"> wrote:</span></span><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>I am having difficulty getting the following example to work using either delay or step:<br></div><div><br></div><div>aMorph := Morph new. <br></div><div>aMorph position: (100@100).<br></div><div>aMorph openInWorld. <br></div><div>30 timesRepeat: [aMorph position: aMorph position +(1@0).
 Transcript show: 'test '; cr.]. <br></div><div>(aMorph position) >= (120@100) ifTrue: [aMorph color: Color yellow].<br></div><div>Transcript show: 'position: ', aMorph position; cr.<br></div><div><br></div><div>For example:<br></div><div><br></div><div>aMorph := Morph new. <br></div><div>aMorph position: (100@100). <br></div><div>aMorph openInWorld. <br></div><div>delay := Delay forMilliseconds: 20.<br></div><div>[30 timesRepeat: [aMorph position: aMorph position +(1@0). delay wait.].] fork. <br></div><div>(aMorph position) >= (110@100) ifTrue: [aMorph color: Color yellow].<br></div><div>Transcript show: 'position: ', aMorph position; cr.<br></div><div><br></div><div>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.<br></div></blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div>Morphic animation is based on stepping. That means, you don't move a Morph repeatedly in a loop, but Morphic tells your morph to update its position repeatedly.<br></div><div><br></div><div>You need to make your own Morph subclass and implement a "step" method. Whenever that method is called, it moves the morph by a little. For example, you could use an existing method called" translateBy:"<br></div><div><br></div><div><div>| aMorph |<br></div><div>aMorph := Morph new openInWorld. <br></div><div>aMorph startStepping: #transformedBy: at: Time millisecondClockValue arguments: {MorphicTransform offset: -3 @ -3} stepTime: 200.<br></div><div><br></div><div>However, it's unlikely no existing method does your specific animation, so you indeed need to implement it, eg<br></div><div><br></div><div>step<br></div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">    self position: self position + (1@0).<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">    (self position) >= (120@100) ifTrue: [self color: Color yellow].<br></div></div><div><br></div></div><div>So this is the Right Way. Without bad hacks you cannot do meaningful animation from a workspace. There is a hack however: If you insert "World doOneCycle" in the while loop of your first example, it will actually work, because it will redraw the world in each loop. However, this would prevent two objects animating independently, that's why the design calls for the "step" method approach.<br></div><div><br></div><div>- Bert -<br></div><div><br></div></div></div></blockquote><div><br></div></div></div></blockquote></div><br></div></div>