したらばTOP ■掲示板に戻る■ 全部 1-100 最新50 | |

スクリプト覚書

58ここな ◆noLKOKOKEo:2010/11/18(木) 22:38:22
内積を算出するサンプルかんせーい

createTextField("test_tx",20,160,280,0,0);
test_tx.autoSize = "center";

createTextField("tx_pos0",30,0,0,32,32);
createTextField("tx_pos1",31,0,0,32,32);
tx_pos0.text = "pos0";
tx_pos1.text = "pos1";

my_mc.onPress = function(){
my_mc.startDrag();
};

my_mc.onRelease = function(){
my_mc.stopDrag();
};

onEnterFrame = function(){

for(i=0;i<2;i++){

_root["tx_pos"+i]._x = _root["mc_pos"+i]._x + 8;
_root["tx_pos"+i]._y = _root["mc_pos"+i]._y - 10;

Dr_test = _root["mc_pos"+i].hitTest(_root._xmouse,_root._ymouse,true);
if(Dr_test == true){
_Dr_POS = "mc_pos" + i;
}
}

_root[_Dr_POS].onPress = function(){
this.startDrag();
};

_root[_Dr_POS].onRelease = function(){
this.stopDrag();
};


keisan();

test_tx.text = vec_num;

};

function keisan(){

//数値の更新
px = my_mc._x;
py = my_mc._y;
//ポイントa
ax = mc_pos0._x;
ay = mc_pos0._y;
//ポイントb(注:ポイントa < b)
bx = mc_pos1._x;
by = mc_pos1._y;

//線分abのベクトル
v1_x = bx - ax;
v1_y = by - ay;

//線分abと垂直のベクトル
tmp = v1_x;
v1_x = -v1_y;
v1_y = tmp;

//ポイントaからのベクトル
v2_x = px - ax;
v2_y = py - ay;

//線分abから見た内積
vec_num = v1_x * v2_x + v1_y * v2_y;

}


新着レスの表示


名前: E-mail(省略可)

※書き込む際の注意事項はこちら

※画像アップローダーはこちら

(画像を表示できるのは「画像リンクのサムネイル表示」がオンの掲示板に限ります)

掲示板管理者へ連絡 無料レンタル掲示板