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;
}
}
在另一個動畫片夾內是否有球動畫片夾? – nikel
@nikel不,這是一個簡單的動畫片段。 – Francisco