Hi everyone,
I’m hoping I’m missing something simple here. I want to display an object (which works) and when my player entity collides with this object the object should disappear. My collision code works but once the collision occurs my game crashes giving me this error:
IndexOutOfBoundsException: Index: 0, Size: 0
As far as I can tell there is an element in my array list at index 0. Can anyone please point out what I’m missing?
thanks!
ArrayList<Test> testList = new ArrayList(); //creates arrayList
void setup()
{
testList.add(new Test((0, 0, 60)); //adds element to arrayList
}
void draw()
{
testList.get(0).showList();
if (testList.get(0).testHit()) //this has been set to return true
{
testList.clear(); //clears arrayList and screen
}
}