Hello,
I'm trying to do the PongTable game and i'stuck with the intersects() method. I know there are other ways to do this but i want to understand my mistake. Method signature is: intersects(Actor other).
What is the correct syntax in my case. I want to call the method from here:
The object i want to call is the Paddle:
The Constractor is in the World class:
public class PongTable extends World
{
public static final int SPEED = 5;
public PongTable() {
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(500, 600, 1);
addObject(new Paddle(), 250, 550);
addObject(new Ball(SPEED), 250, 270);
}
}
The error i get when i write something like: (intersects(Paddle)) is
intersects(greenfoot.Actor) in greenfoot actor cannot be applied to ....
Sorry if thats to much code for a small problem.
Thank you in advance.
public class Ball extends Actor
{
private int vSpeed;
private int hSpeed;
int margin = getImage().getWidth()/2;
public Ball (int speed) {
vSpeed = speed;
hSpeed = speed;
}
public void act()
{
move();
if (intersects(?????????)) {
//do something
}
} public class Paddle extends Actor
{
public static final int WIDTH = 100, HEIGHT=20, SPEED=5;
public int hits;
public Paddle () {
GreenfootImage img = new GreenfootImage (WIDTH, HEIGHT);
img.fillRect (0, 0, WIDTH, HEIGHT);
setImage (img);
hits =0;
}
public void act()
{
movePaddle();
}

