✔ 最佳答案
一、先修改 tool 的宣告,如下
https://tw.knowledge.yahoo.com/question/question?qid=1514052605911
二、在一開始、第一行加上這句
var life:int = 0;
三、修改 hitTest2 如下
function hitTest2(event:Event):void
{
var a:uint = 0;
var b:uint = 0;
var c:uint = 0;//■
var me:memc = null;
var enemy:enemymc = null;
var tool:toolmc = null;//■
for (a = 0; a < meArea.numChildren; a++)
{
me = meArea.getChildAt(a) as memc;
for (b = 0; b < enemyArea.numChildren; b++)
{
enemy = enemyArea.getChildAt(b) as enemymc;
if (enemy.hitTestObject(me))
{
//meArea.removeChild(me);
if(life-10>=0){life-=10;}//■減分
}
}
for (c = 0; c < toolArea.numChildren; c++)
{
tool = toolArea.getChildAt(c) as toolmc;//■
if (tool.hitTestObject(me))
{
if(life+10<=100){life+=10;}//■加分
}
}
}trace(life)//■
}