Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

animation in squeak smalltalk

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

is there a build in way to create animation in squeak smalltalk ?

like image 520
2Big2BeSmall Avatar asked Jun 07 '15 18:06

2Big2BeSmall


2 Answers

Yes, there is a built in way:

Make a subclass of Morph and implement the two methods

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

A minimal example:

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

MovingMorph>>stepTime

stepTime
    ^ 100

MovingMorph>>step

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

Now open a MovingMorph in the World (MovingMorph new openInWorld) and control the animation with startStepping and stopStepping.

like image 88
MartinW Avatar answered Oct 19 '22 10:10

MartinW


While it is possible to show animations using Morphic stepping, the Animations Project takes a bit further, and provides a simple interface to use short animations:

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

Things like fade-in or fade-out or similar are even simpler:

myMorph fadeOut.
like image 26
Tobias Avatar answered Oct 19 '22 09:10

Tobias