I am having difficulty getting the following example to work using either delay or step: aMorph := Morph new.
aMorph position: (100@100). aMorph openInWorld.
30 timesRepeat: [aMorph position: aMorph position +(1@0).
Transcript show: 'test '; cr.].
(aMorph position) >= (120@100) ifTrue: [aMorph color: Color yellow]. Transcript show: 'position: ', aMorph position; cr. For example: aMorph := Morph new.
aMorph position: (100@100).
aMorph openInWorld.
delay := Delay forMilliseconds: 20.
[30 timesRepeat: [aMorph position: aMorph position +(1@0). delay wait.].] fork.
(aMorph position) >= (110@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. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
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. 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:" | aMorph | aMorph := Morph new openInWorld. aMorph startStepping: #transformedBy: at: Time millisecondClockValue arguments: {MorphicTransform offset: -3 @ -3} stepTime: 200. However, it's unlikely no existing method does your specific animation, so you indeed need to implement it, eg step self position: self position + (1@0). (self position) >= (120@100) ifTrue: [self color: Color yellow]. 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. - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
No, you have to put that test in the step method, because it has to be checked every time the position changes. 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). - Bert - On Thu, Oct 12, 2017 at 7:39 PM, obrienj <[hidden email]> wrote:
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Bert Freudenberg
My little OpenGL spaceship firing a missile animation had this annoying pause every so-often, as the GC activated and froze the screen. Was hoping that Craig Latta would release a minimal Spoon image that allowed me to load the OpenGL plugin code, because the GC in the minimal image took about 1/50th (or less) of the time that the complete image takes, but he got sidetracked with his Caffeine project. Lawson
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." -Brian Kernighan
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Hi Lawson,
Actually smooth animation in Squeak is possible. The best I've seen is at: This is pure squeak/morphic, using stepping. This isn't to say there aren't issue lurking about, of course. -cbc On Thu, Oct 12, 2017 at 3:41 PM, LEnglish <[hidden email]> wrote:
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by LawsonEnglish
Unfortunately, can’t run that without windows, if I read the title correctly (“for windows”) Also, I was using OpenGL, which might have complicated things. Thanks for the link. I’ll try to figure out what they did differently than my experiment. L
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by LawsonEnglish
Hi Lawson, smooth animation in Squeak is indeed possible. :) I use the Animation [1] package in Widgets [2] and Vivide [3] to improve UX with several (simple) effects (sorry for the GIF artifacts):
Best, Marcel
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by LawsonEnglish
On 13-10-17 00:41, LEnglish wrote:
> Because of garbage collection issues, smooth animation in Squeak isn’t really possible. That shouldn't stop you as that problem will solve itself next year with the incremental garbage collector. Stephan _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |