0
var i:Number;
for (i=0;i<6;i++)
{
var brick:Sprite=new Sprite();
brick.graphics.beginFill(0x02589E);
brick.graphics.drawRect(0,0,70,7);
brick.graphics.endFill();
brick.y=10;
brick.x=12+(80*i);
addChild(brick);
}
addEventListener(Event.ENTER_FRAME,destroy);
var ball:Sprite=new Sprite();
ball.graphics.beginFill(0xff0000);
ball.graphics.drawCircle(0,0,7);
ball.graphics.endFill();
ball.x=200;
ball.y=230;
addChild(ball);
.......對球跑動一些代碼.......碰撞無法正常工作AS3
function destroy(e:Event):void
{
if(ball.hitTestObject(brick)){
removeChild(brick);
}
}
當球與磚碰撞,只有最後一個磚刪除。但如果球與磚塊相撞,我想單獨移除所有的磚塊。