Hello All... Pretty new to actionscript 3 and only used actionscript previously for simple menu and button programming.
Currently I am working on game programming for College and I am having a little difficulty.
I am using a Block Breaker game tutorial to get the understanding of AS3 and have followed it to the letter to a point, but now I want to do something not offered in the tutorial. I do not want my ball to start moving until the Player clicks his mouse button.
originally the listener was set to Event.ENTER_FRAME and that worked to start the ball immediately.
I changed it to:
Code:
mcBall.addEventListener(MouseEvent.CLICK, moveball);
and couldnt get it to work.... So I adjusted it to
Code:
stage.addEventListener(MouseEvent.CLICK, moveball);
and now It will move the ball slightly each time I click the mouse. I want the movements to continue AFTER the click, and not just activate each time I click the button.
Here is the function code for "moveball"
Code:
//Ball Movement Function
function moveball (event:MouseEvent):void{
mcBall.x += ballXSpeed
mcBall.y += ballYSpeed
//Rightside Bounce
if(mcBall.x >= stage.stageWidth-mcBall.width){
ballXSpeed *= -1
}
//leftside Bounce
if(mcBall.x <= 0){
ballXSpeed *= -1
}
//bottom Bounce
if(mcBall.y >= stage.stageHeight-mcBall.height){
ballYSpeed *= -1
}
//top Bounce
if(mcBall.y <= 0){
ballYSpeed *= -1
}
if(mcBall.hitTestObject(mcPaddle)){
calcBallAngle();
}
}
Any help would be appreciated Thankyou