简体   繁体   English

吱吱声中的动画片

[英]animation in squeak smalltalk

I have a simple morph in squeak smalltalk. 我有一个简单的变形吱吱声smalltalk。 I want to move it from x1,y1 to x2,y2 (animation) with 5 seconds (or 10 seconds) 我想用5秒(或10秒)将它从x1,y1移动到x2,y2(动画)

is there a build in way to create animation in squeak smalltalk ? 是否有一种在吱吱声中创建动画的方法?

Yes, there is a built in way: 是的,有内置的方式:

Make a subclass of Morph and implement the two methods 创建Morph的子类并实现这两个方法

  • stepTime (time between steps in milliseconds) and stepTime(步长之间的时间,以毫秒为单位)和
  • step (is sent to the morph in regular intervals of time) step(以固定的时间间隔发送到变形)

A minimal example: 一个最小的例子:

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

MovingMorph>>stepTime MovingMorph >> stepTime

stepTime
    ^ 100

MovingMorph>>step MovingMorph >>步

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 . 现在在世界中打开MovingMorph( MovingMorph new openInWorld )并使用startSteppingstopStepping控制动画。

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: 虽然可以使用Morphic步进显示动画,但动画项目需要更进一步,并提供一个简单的界面来使用短动画:

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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM