リファレンス URL:point_distance(x1, y1, x2, y2);

「実数型 (real) 」として返り値。

任意の二点間距離を返す関数。

オブジェクト A のx1, y1座標とオブジェクト B のx2, y2座標があったとして、この二点間の距離を測りたい場合などに用いられる。

これと似た働きをする distance_to_point という関数もあるが、distance_to_point(x1, y1); は与えられる引数が 2 つで原点は関数を呼び出したオブジェクト・インスタンスの x0, y0 に固定される点が異なる。

スクリプト・サンプル
if self.mbc==false { if mouse_check_button_pressed(mb_left){ self.mbc=true; self.orx=mouse_x; self.ory=mouse_y; }//一度目、マウスボタンをクリックしたらその地点を原点とし記録 } else {//IF TRUE THEN if mouse_check_button_pressed(mb_left){ self.mbc=false;//二度目のマウスボタンをクリックで距離計測を終了 } else { var a,b,c,d; a=self.orx; b=self.ory; c=mouse_x; d=mouse_y; draw_line(a,b,c,d);//線を描く draw_text(a,b,"Distance = "+string(point_distance(a,b,c,d))); } }
Functions/point_distance
WordPress › Error

There has been a critical error on this website.

Learn more about troubleshooting WordPress.