Friday, July 11, 2008
AE / findAngle(the loc of grc "blue",the loc of grc "Red")
ふたつのオブジェクトのロケーションのアングルを返します。
ふたつのオブジェクトが上下にある場合: 360, 80 または、 180, 0
ふたつのオブジェクトが左右にある場合: 90, 270 または、 270, 90
例では、arcAngle = 340 の、ブルーとレッドのグラフィック「oval」を、fineAngle によって startAngle を変化させて、互いに向かい合っているようにしています。
-- カード内のスクリプト
on openCard
set the arcAngle of grc "blue" to 340
set the arcAngle of grc "red" to 340
end openCard
-- arcAngle でグラフィックの開いた部分は、 startAngle が起点となっているので
-- アングルの中間で互いが向かい合うように調整する
function adjustAngle
return (360 - the arcAngle of grc "blue") div 2
end adjustAngle
command moveAngle
put findangle(the loc of grc "blue",the loc of grc "Red") into test1
put findangle(the loc of grc "Red",the loc of grc "blue") into test2
if test1=0 then put 360 into test1
if test2=0 then put 360 into test2
set the startAngle of grc "blue" to 90 -test1 +adjustAngle()
set the startAngle of grc "Red" to 90 -test2 +adjustAngle()
end moveAngle
-- それぞれのグラフィック内のスクリプト
on mouseMove
moveAngle
pass mouseMove
end mouseMove
on mouseDown
grab me
end mouseDown
始めにAnimation Engineを開いて、start using stack "animationEngine"
サンプルスタックは、下記をメッセージボックスにコピペしてリターンキーを
go stack url "http://homepage.mac.com/kenjikojima/jrevnote/findAngle.rev"