AS2問題。
載入數個物件,要設定其座標在一"圓形"的範圍內的隨機位置。
該怎麼做呢?
我只知道如何在一個矩形的範圍內出現,ex:
for ( i=1; i<=30; i++ ){
minX = tree_mc._x ;
maxX = tree_mc._x + tree_mc.area_mc._width;
minY = tree_mc._y;
maxY = tree_mc._y + tree_mc.area_mc._height;
attachMovie( "apple", "apple"+i, i);
this["apple"+i]._x = Math.floor ( (maxX-minX)*Math.random()+minX );
this["apple"+i]._y = Math.floor ( (maxY-minY)*Math.random()+minY );
}
可是這樣子我的蘋果會飛到蘋果樹外面...囧
好煩惱~"~
請問該怎麼改呢?
--
U.Cafe 個人網站 http://unas.com.tw/
U.Design 作品集網站 http://unas.com.tw/U_Design/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.46.157.193