0

## ActionScript 撞擊測式問題!!!

Hi ALL

for CS5.5
https://www.asuswebstorage.com/navigate/share/GYYI459SIY

https://www.asuswebstorage.com/navigate/share/GYYQUS9SIY

### 1 個回答

4
wordsmith
iT邦高手 1 級 ‧ 2012-02-24 17:55:52

ck123 iT邦新手 5 級 ‧ 2012-02-24 23:48:37 檢舉

ck123 iT邦新手 5 級 ‧ 2012-02-25 01:52:28 檢舉

wordsmith iT邦高手 1 級 ‧ 2012-02-25 13:15:43 檢舉

reaction.ballCounter =0

reaction.ballCounter++

amissile.name = "ball"+reaction.ballCounter;

wordsmith iT邦高手 1 級 ‧ 2012-02-25 13:20:22 檢舉

wordsmith iT邦高手 1 級 ‧ 2012-02-25 13:23:52 檢舉

``````&lt;pre class="c" name="code">import flash.events.MouseEvent;
import flash.events.Event;

//增加一個放砲彈的陣列
reaction.allBalls = [];

function rotatee(e:Event)
{
var theX:int = mouseX - theArrow.x;
var theY:int = (mouseY - theArrow.y) * -1;
var angle = Math.atan(theY/theX)/(Math.PI/180);
if (theX&lt;0)
{
angle +=  180;
}
if (theX>=0 && theY&lt;0)
{
angle +=  360;
}
theArrow.rotation = (angle * -1) + 1;

}

function froth(MouseEvent){
var amissile:missile=new missile();
amissile.x = 18;
amissile.y = 158;
amissile.rotation = theArrow.rotation;
//把砲彈放進陣列
reaction.allBalls.push(amissile);
}
``````
wordsmith iT邦高手 1 級 ‧ 2012-02-25 13:26:24 檢舉

``````&lt;pre class="c" name="code">function go(e)
{
this.x -=  1;
//取得放砲彈陣列的長度
var total = myroot.reaction.allBalls.length;
//檢查是否撞擊到
for(var i=0; i&lt;total;i++)
{
if (this.hitTestObject(myroot.reaction.allBalls[i]))
{
myroot.score += 10;
this.removeEventListener(Event.ENTER_FRAME,go);
myroot.removeChild(this);
}
}

}
``````

wordsmith iT邦高手 1 級 ‧ 2012-02-25 13:32:39 檢舉

wordsmith iT邦高手 1 級 ‧ 2012-02-25 13:37:00 檢舉