AS3 Classes, Collisions and Functions


Im working in FlashDevelop on a ‘breakout’ game where you control a paddle with your mouse and a ball bounces around the screen and breaks blocks.

Right now I have a Main, Paddle, and Ball class. In the main class I added a Paddle called player as a public static variable. In my Ball class I have a collisionCheck() function. This way I can access ‘player’ from within my Ball class for testing collisions.

At somepoint in the game there will be a powerup that adds mutiple balls to the stage. Right now I have a function in the main class call addBall() to add a new Ball to the stage.

I am now running into trouble. Working on the collision check method in my Ball class, I dont know how to check if a ball is hitting another ball because as of right now, balls are being added with the addBall function, so they can’t be declared as public static variables. :confused:

I included the .as files as attachments. This is my first game in as3. Maybe I am going about creating this in the wrong way, I am open to big changes. Can anyone help??