2013-10-08 42 views
0

我在AS3做了一個pong遊戲。然而,當球擊中我的槳時,我想移除它的一部分(槳)。 我的球和我的槳都是動畫片段。 我該怎麼做?刪除的最佳方式是什麼,而不是整個動畫片段,而只是其中的一部分。Flash AS3刪除動畫片段的部分

這裏是我的代碼:

import flash.events.Event; 


var ballSpeedX:int = 4; 
var ballSpeedY:int = 4; 

init(); 

function init():void { 
    stage.addEventListener(Event.ENTER_FRAME, loop); 
} 

function loop(e:Event):void { 

    playerPaddle.x = mouseX; 

    if(playerPaddle.hitTestObject(ball)){ 
     if(ballSpeedY >= 0){ 
      ballSpeedY *= -1; 
      ball.removeSelf(); 
     } 
    } 

    if(playerPaddle.y - playerPaddle.height/2 < 0){ 
     playerPaddle.y = playerPaddle.height/2; 

    //check if bottom of paddle is below bottom of screen 
    } else if(playerPaddle.y + playerPaddle.height/2 > stage.stageHeight){ 
     playerPaddle.y = stage.stageHeight - playerPaddle.height/2; 
    } 

    ball.x += ballSpeedX; 
    ball.y += ballSpeedY; 

    if(ball.x <= ball.width/2){ 
     ball.x = ball.width/2; 
     ballSpeedX *= -1; 

    }else if(ball.x >= stage.stageWidth-ball.width/2){ 
     ball.x = stage.stageWidth-ball.width/2; 
     ballSpeedX *= -1; 

    } 

    if(ball.y <= ball.height/2){ 
     ball.y = ball.height/2; 
     ballSpeedY *= -1; 

    } else if(ball.y >= stage.stageHeight-ball.height/2){ 
     ball.y = stage.stageHeight-ball.height/2; 
     ballSpeedY *= -1; 

    } 
} 
+0

在另一個動畫片夾內是否有球動畫片夾? – nikel

+0

@nikel不,這是一個簡單的動畫片段。 – Francisco

回答

0
Graphics.beginFill(0,0) 

可能是最好的方法。

這就像與橡膠繪畫(第二PARAM裝置透明

可以走動lineTo/curveTo然後提交endFill

相關問題