Forcing Morphic Updates?

Bob Arning arning at charm.net
Sun Jun 15 13:00:32 UTC 2003


On Sun, 15 Jun 2003 00:39:52 -0500 (CDT) Aaron J Reichow <reic0024 at d.umn.edu> wrote:
>For example, if I execute the following code:
>
>| m |
>m _ Morph new openInWorld.
>m position: 0 at 0.
>0 to: (World width - m width) do: [ :n | m position: n at 0 ].
>
>I just end up with the morph at the upper right hand of the screen, with
>no animation.  This problem has also come up with updating a
>PluggableTextMorph while there is processing going on.
>
>This is probably something which has been discussed here a number of
>times, and is probably pretty simple. The only thing I've seen so far is
>the #step system, which works well for this, but there has to be another
>way- subclassing every morph you want to animate a little seems to be a
>bit much.

Aaron,

One way to do this that's not too much trouble is to have *one* morph that knows about animation and let it move everything that needs moving. So then you could say

	| m |
	a _ AnimatorMorph new position: -100 at -100; openInWorld.
	m _ Morph new openInWorld.
	m position: 0 at 0.
	a move: m to: (World width - m width)@0 inMilliseconds: 1500.

----------
move: target to: destination inMilliseconds: deltaTime

	animations add: {
		target.
		target position.
		destination.
		Time millisecondClockValue.
		deltaTime.
	}.
----------
step

	| now |

	now _ Time millisecondClockValue
	animations do: [ :each |
		fraction _ now - each fourth / each fifth min: 1 max: 0.
		each first position: (each third - each second * fraction + each second) rounded.
	].
	animations _ animations reject: [ :each | now >= (each fourth + each fifth) ].
----------

Cheers,
Bob



More information about the Squeak-dev mailing list