Smalltalk fiddle animation

I have a simple morph in squeak smalltalk. I want to move it from x1, y1 to x2, y2 (animation) from 5 seconds (or 10 seconds)

Is there a way to create animations in squeak smalltalk?

+4
source share
2 answers

Yes, there is a built-in way:

Subclass Morph and implement two methods

  • stepTime (time between steps in milliseconds) and
  • (sent to the morph at regular time intervals)

Minimal example:

Morph subclass: #MovingMorph
    instanceVariableNames: ''
    classVariableNames: ''
    category: 'MovingMorph'

MovingMorph → stepTime

stepTime
    ^ 100

MovingMorph → step

step
    self position: self position + (1@1)

Now open MovingMorph in the world ( MovingMorph new openInWorld) and control the animation with startSteppingand stopStepping.

+6
source

, , Project ,

AnimPropertyAnimation new
   duration: 500;
   target: myMorph;
   property: #position; "There should be a message called #position:."
   startValue: 10@10;
   endValue: 100@100;
   start.

, , :

myMorph fadeOut.
+3

All Articles