So I'm using colour collision detection for my game and I'm getting the follow error.
java.lang.IndexOutOfBoundsException: Y is out of bounds. It was: 604 and it should have been smaller than: 600
at greenfoot.GreenfootImage.getRGBAt(GreenfootImage.java:579)
at greenfoot.GreenfootImage.getColorAt(GreenfootImage.java:536)
at Zorbo.onGround(Zorbo.java:50)
at Platformer.checkKeys(Platformer.java:164)
at Platformer.act(Platformer.java:45)
at greenfoot.core.Simulation.actWorld(Simulation.java:571)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:506)
at greenfoot.core.Simulation.runContent(Simulation.java:213)
at greenfoot.core.Simulation.run(Simulation.java:203)
I'm almost certain that it has to do with a method trying to get a colour at a border when past the border there is no colour. The border being the edge of the program screen.
This is the code at line 50 in the zorbo class.
This is the code on line 164 in Platformer class.
The line 45 code is just running the checkKeys method.
public boolean onGround() { if (getWorld().getBackground().getColorAt(getX(), getY()+18).equals(platform) || onPlatform()) { return true; } return false; }
if ((!zorbo.onGround() || zorbo.onPlatform()) && facingRight) { zorbo.setImage("/Sprites/jump.png"); }