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

2012/10/17

Chapter 6.34 question

yasumiishi yasumiishi

2012/10/17

#
I wonder if someone can help me solve this issue ... I have below code. Every time I compile, I get error message "at java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0". I changed around some setttings but the error message doesn't go away ;-( What am I doing wrong? Thank you!!!! ---- data private static final double GRAVITY = 6.0; private static final Color defaultColor = new Color(255, 216, 0); private boolean touched = false; private double mass; private int size; private GreenfootImage image; --- private void bounceAtEdge() { if (getX() == 0 || getX() == getWorld().getWidth()-1) { setLocation((double)getX(), (double)getY()); getMovement().revertHorizontal(); accelerate(0.4); changeColor(); } else if (getY() == 0 || getY() == getWorld().getHeight()-1) { setLocation((double)getX(), (double)getY()); getMovement().revertVertical(); accelerate(0.4); changeColor(); } } private void changeColor() { int r = Greenfoot.getRandomNumber(255); int g = Greenfoot.getRandomNumber(255); int b = Greenfoot.getRandomNumber(255); GreenfootImage image = new GreenfootImage (size, size); image.setColor (new Color(r,g,b)); image.fillOval(0, 0, size-1, size-1); setImage (image); }
yasumiishi yasumiishi

2012/10/17

#
Well .. never mind. I reply to myself. Looks like I forgot below :-( this.size = size;
You need to login to post a reply.