钓鱼方法钓鱼技巧钓鱼攻略钓鱼秘籍钓鱼装备,尽在渔夫子

WaveMotion类

WaveMotion.as

import Motion;
class WaveMotion extends Motion {
  var amp:Number;
  //振幅
  var period:Number;
  //周期
  var offset:Number;
  //偏移量
  var timeShift:Number;
  //时移
  function getPosition(t:Number):Number {
    if (t == undefined) {
      t = this.time;
    }
    return (this.amp*Math.sin((t-this.timeShift)*(2*Math.PI)/this.period)+this.offset);
  }
  function setAmp(a:Number):Void {
    if (a != undefined) {
      this.amp = a;
    }
  }
  function getAmp():Number {
    return this.amp;
  }
  function setPeriod(p:Number):Void {
    if (p != undefined) {
      this.period = p;
    }
  }
  function getPeriod():Number {
    return this.period;
  }
  function setOffset(f:Number):Void {
    if (f != undefined) {
      this.offset = f;
    }
  }
  function getOffset():Number {
    return this.offset;
  }
  function settimeShift(t:Number):Void {
    if (t != undefined) {
      this.timeShift = t;
    }
  }
  function gettimeShift():Number {
    return this.timeShift;
  }
  function setFreq(f:Number):Void {
    this.setPeriod(1/f);
  }
  function getFreq():Number {
    return 1/this.getPeriod();
  }
  function setWavePhysics(amp:Number, period:Number, timeShift:Number, offset:Number) {
    this.setAmp(amp);
    this.setPeriod(period);
    this.settimeShift(timeShift);
    this.setOffset(offset);
  }
  /********************************************/
  function WaveMotion(obj:MovieClip, prop:String, begin:Number, amp:Number, period:Number, duration:Number,timeShift:Number, useSeconds:Boolean) {
    super(obj, prop, begin, duration, useSeconds);
    this.setOffset(begin);
    this.setAmp(amp);
    this.setPeriod(period);
    this.settimeShift(timeShift);
  }
}


应用WaveMotion类可以轻松的创建波形动画:
在舞台上放置一个名为"ball"的电影剪辑,在主场景的时间轴上加上如下代码:

 import WaveMotion;
 var waveX:WaveMotion=new WaveMotion(ball,"_x",250,80,2,0,0,true);

标签:flash
分类:生活点滴| 发布:渔夫子| 查看: | 发表时间:2006-11-18
原创文章如转载,请注明:转载自渔夫子 http://www.yufuzi.net/
本文链接:http://www.yufuzi.net/post/flash_WaveMotion.html

相关文章

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

1 #大朋友
大朋友 其實用math.cos便能簡單的做到....
2006-12-26 01:34:25 【REPLY】