In my breakout game I'm trying to switch to a new level and the static/non-static reference keeps popping up. I've read previous discussions, but they don't help with my situation. Here is the malfunctioning code for my second paddle and second world:
World2:
Paddle2:
public static void ballIsOut2()
{
Paddle2.newBall2();
lifeLost();
}/**
* When the paddle gets created, create a ball as well.
*/
public void addedToWorld(World2 world2)
{
newBall2();
}
/**
* Act - do whatever the Paddle wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if (Greenfoot.isKeyDown ("left")) {
moveSideways(-9);
}
if (Greenfoot.isKeyDown ("right")) {
moveSideways(9);
}
if (haveBall2() && Greenfoot.isKeyDown ("space")) {
releaseBall2();
}
}
public void moveSideways(int dist)
{
setLocation (getX() + dist, getY());
if (myBall2 != null) {
myBall2.move (dist);
}
}
public void newBall2()
{
myBall2 = new Ball2();
getWorld2().addObject (myBall2, getX(), getY()-27);
}
public boolean haveBall2()
{
return myBall2 != null;
}
public void releaseBall2()
{
myBall2.release();
myBall2 = null;
}

