以下の内容はhttps://unageanu.hatenablog.com/entry/20081108/1226136325より取得しました。


tweenerでスプライトを移動するアニメーションを作る。

tweenerFlex/Flashで使えるトウィーンライブラリです。定期的にスプライトの属性を変更することで、

  • スプライトの移動
  • スプライトの透明化

といったアニメーションがさくっと作成できます。

インストール

tweenerのサイトからダウンロードします。Flexで使うので、「tweener_1_31_74_as3_swc.zip」を使用しました。展開したswcはlibrary-pathに追加して使います。

$ mxmlc -library-path=tweener.swc  Sample.as 

クリックでスプライトを移動するアニメーションのサンプル

以下はtweenerを使ってクリックした位置にスプライトを移動するサンプルです。

package {
	
  import flash.display.*;
  import flash.events.MouseEvent;
  import caurina.transitions.Tweener; // Tweenerのクラスをインポート

  public class Sample extends Sprite  {

    public function Sample(){
      
      // 円
      var circle:Sprite = new Sprite();
      addChild(circle);
      var g:Graphics = circle.graphics;
      g.beginFill( 0xFF4444 );
      g.drawCircle( 0, 0, 20 );
      g.endFill();
      
      // イベントハンドラを設定
      stage.addEventListener(MouseEvent.CLICK, function(ev:flash.events.MouseEvent):void {
          // Tweenerでクリックした位置にスプライトを移動する。
          Tweener.addTween( circle, {x:ev.stageX, y:ev.stageY, time:0.5, transition:"linear"});
      });
        
    }
  }
}

実行はこちら

なかなか便利。




以上の内容はhttps://unageanu.hatenablog.com/entry/20081108/1226136325より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14