I am making a 3D game and when the ship shoots a bullet it shrinks to make it look like its going into the distance. My problem is when it's width and length reach 0 it comes up with an error, i need to work around this error by making the bullet disappear when it reaches width 1 and length 1 so the game doesn't get an error.
the error:
java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1016)
at java.awt.GraphicsConfiguration.createCompatibleImage(GraphicsConfiguration.java:186)
at greenfoot.util.GraphicsUtilities.createCompatibleTranslucentImage(GraphicsUtilities.java:189)
at greenfoot.GreenfootImage.scale(GreenfootImage.java:408)
at Bullet.shrink(Bullet.java:39)
at Bullet.act(Bullet.java:23)
at greenfoot.core.Simulation.actActor(Simulation.java:604)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:562)
at greenfoot.core.Simulation.runContent(Simulation.java:221)
at greenfoot.core.Simulation.run(Simulation.java:211)
Thats the code i am using to make the bullet shrink
public void shrink() { int percentage = 99; GreenfootImage image = getImage(); image.scale(image.getWidth()*percentage/100, image.getHeight()*percentage/100); }