I’m making a Pong game in FlashPunk. In my “Play.as” world-class, I add new Ball, new PlayerPaddle and new EnemyPaddle in the constructor.
In my EnemyPaddle class, I am writing a function to move the paddle after the ball. I need to access the y variable of the ball object for this, but I don’t know how. Basically, my code would look something like this:
private function move():void {
if (y+height/2 < [ball].y+[ball].height/2) {
y += speed*FP.elapsed;
}
}
}
How do I access the y property of the ball object? It’s not assigned to any variable as far as I’m concerned, all I’m doing is “add(new Ball);”… Any help is greatly appreciated!