Friday, July 25, 2008
AE / constrainElliptical
楕円起動をオブジェクトがマウスで動きます。ハンドラーの「on mouseMove」ではなく、constrainElliptical でカスタムプロパティに設定された、 uAllowConstrainDrag によってドラッグできます。楕円起動は同じく、constrainEllipticalで設定されるカスタクプロパティ constrainElliptical に、ロケーション、楕円の左右の半径、天地の半径で決められます。
基本構文:
set the constrainElliptical of (マウスダウンで動くオブジェクト) to \
(楕円のロケーション x, y ), (楕円の左右 / 2), (楕円の天地 / 2)
サンプル:
楕円軌道をグラフィック Oval で作って、名前は「myOrbit」。マウスで動くオブジェクトをグラフィックで作って名前を「myBlue」としたら、メセージボックスから
set the constrainElliptical of grc "myBlue" to \
the loc of grc "myOrbit",the width of grc "myOrbit"/2,the height of grc "myOrbit"/2
grc “myBlue” には、右図の4つのカスタムプロパティが作られます。
一旦 constrainElliptical を設定したら、グラフィックの楕円軌道を削除しても、オブジェクトは楕円上を回ります。
ドキュメントによると、「constrainElliptical」を設定した場合、mouseDown, mouseUp, mouseRelease, mouseMove 等を同時に使用すると、問題が起こることがあるので代わりに
mouseDown - constrainEllipticalInit
mouseUp - constrainEllipticalExit
mouseRelease - constrainEllipticalExit
mouseMove - constrainEllipticalCallback
を使用するようにとあります。
ユーザーのマウスの移動ではなく、 正円軌道をオブジェクトが自動で回転するコマンド moveCircular と、楕円上をオブジェクトが自動で回転するコマンド moveElliptical があります。
始めにAnimation Engineを開いて、start using stack "animationEngine"
サンプルスタックは、下記をメッセージボックスにコピペしてリターンキーを
go stack url "http://homepage.mac.com/kenjikojima/jrevnote/constrainElliptical.rev"