This site requires JavaScript, please enable it in your browser!
Greenfoot back
sebastianb
sebastianb wrote ...

2017/2/6

cannot find symbol

sebastianb sebastianb

2017/2/6

#
public class Paddle extends Actor { private Ball myBall; public boolean attCheck= false; public Paddle() { GreenfootImage myImage = getImage(); int myNewHeight = (int)myImage.getHeight()/2; int myNewWidth = (int)myImage.getWidth()/2; myImage.scale(myNewWidth, myNewHeight); } public void incSize() { GreenfootImage myImage = getImage(); int myNewHeight = (int)myImage.getHeight()/2; int myNewWidth = (int)myImage.getWidth()/2+55; myImage.scale(myNewWidth, myNewHeight); } public void addedtoWorld(World world) { newBall(); } public void act() { if (Greenfoot.isKeyDown("left")) moveSideways(-8); if (Greenfoot.isKeyDown("right")) moveSideways(8); if (haveBall() && Greenfoot.isKeyDown ("space")) { releaseBall(); } } public void moveSideways(int dist) {setLocation(getX() + dist, getY()); if(myBall!= null ) myBall.move(dist); } public void newBall() { myBall= new Ball(); getWorld().addObject (myBall, getX()+6, getY()+18); } public boolean haveBall() { return myBall != null; } public void releaseBall() { myBall.release(); myBall = null; } }
Super_Hippo Super_Hippo

2017/2/6

#
Where is the error pointing at?
danpost danpost

2017/2/6

#
What import statements do you have at the top of the class code?
sebastianb sebastianb

2017/2/7

#
import greenfoot.*;
sebastianb sebastianb

2017/2/7

#
public void releaseBall() { myBall.release(); myBall = null; } here is the error
Super_Hippo Super_Hippo

2017/2/7

#
Does the Ball class have a public 'release' method?
You need to login to post a reply.