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

2018/6/7

IndexOutOfBounds Exception?

aayu1004 aayu1004

2018/6/7

#
Hello, I have an actor that is support to teleport to a different location as soon as its x position reaches a certain value. But for some reason, the program is giving me this exception: java.lang.IndexOutOfBoundsException: X is out of bounds. It was: 485 and it should have been smaller than: 37 What does this mean and how can I solve it?
if (getX() == 927)
{
        setLocation(44, getY());
}
else if (getX() == 44)
{
        setLocation(927, getY());
}
My actor's dimensions are: 37 x 42
danpost danpost

2018/6/7

#
aayu1004 wrote...
Hello, I have an actor that is support to teleport to a different location as soon as its x position reaches a certain value. But for some reason, the program is giving me this exception: java.lang.IndexOutOfBoundsException: X is out of bounds. It was: 485 and it should have been smaller than: 37
Please show (copy/paste) the entire error output.
What does this mean and how can I solve it? << Code Omitted >>
This cannot have anything to do with the error. However, it will cause the actor to jump back and forth between the "edges" if landing at one of those x-coordinate locations.
You need to login to post a reply.