Dear David, It's *EXACTLY* what i needed. Thank you very much ! By the way, anyone got an idea why if the line "Transcript show: (pos asString);cr." is commented out or the Transcript Window is closed, i don't get the animation but only the final state of the animation ? (see code belows).
Thank you ! |m1 m2| m1:=Morph new. m1 extent:800@600. m1 color:Color blue. m1 center: Display center. m1 openInWorld. m1 clipSubmorphs:true. m2:=Morph new. m2 extent:200@200. m2 color:Color red. m1 addMorph: m2. m2 center: m1 center. 1 to:200 do:[:el| |pos| (Duration seconds:0.01) asDelay wait. pos:=(m2 position x -5)@(m2 position y). ((pos x + m2 width) >= (m1 position x)) ifFalse:[ pos:=((m1 position x + m1 width)@ m2 position y). ]. "Transcript show: (pos asString);cr." m2 position:pos. ].
2012/7/19 <[hidden email]> Send Beginners mailing list submissions to _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
patrick dudjalija wrote:
> It's *EXACTLY* what i needed. You are welcome. > By the way, anyone got an idea why if the line "Transcript show: (pos > asString);cr." is commented out or the Transcript Window is closed, i don't > get the animation but only the final state of the animation ? You blocked Morphic's UI loop, so that your morph doesn't update the screen. As Tobias said, try to use Morphic's built-in hooks to step animation, as shown here: http://stephane.ducasse.free.fr/FreeBooks/CollectiveNBlueBook/morphic.final.pdf Once I understood how timing works, I found step easier than iteration. It is more fun too, as you can co-ordinate simultaneous animations. However the following quick ugly hack works. I send a refreshWorld message to m1 after each iteration. The UI loop is still blocked, which is probably not what you want, but you can see the animation without a transcript. |m1 m2| m1:=Morph new. m1 extent:800@600. m1 color:Color blue. m1 center: Display center. m1 clipSubmorphs: true. m1 openInWorld. m2:=Morph new. m2 extent:200@200. m2 color:Color red. m1 addMorph: m2. m2 center: m1 center. 1 to:200 do:[:el| |pos| (Duration seconds:0.01) asDelay wait. pos:=(m2 position x -5)@(m2 position y). ((pos x + m2 width) >= (m1 position x)) ifFalse:[ pos:=((m1 position x + m1 width)@ m2 position y). ]. m2 position:pos. m1 refreshWorld. ]. Have fun! _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |