I have objects that can be dragged around. Works fine.
I have an area in the world where they can be dragged into so that things happen. Works fine (so far).
When those objects get drag'n'dropped into the area, they get centered into the middle of the area. Works fine.
When those objects don't hit the area nothing happens. Works fine.
Problem is, the moment the objects aren't dragged inside enough and stick halfway in and halfway out an error pops up and everything stops. I wonder why. Either it is intersecting or it is not, no? What can I do to work around this?
(Error message is:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:638)
at java.util.ArrayList.get(ArrayList.java:414)
at Vocab.checkVocabID(Vocab.java:123)
at Vocab.dragndrop(Vocab.java:103)
at Vocab.act(Vocab.java:78)
public void checkVocabID() { Actor draggedWord = getOneIntersectingObject(TaskField.class); if (draggedWord != null && !isDragged){ hitTaskField = true; World myWorld = getWorld(); TaskWorld taskworld = (TaskWorld)myWorld; if(draggedWord.getClass() == TaskField.class) { int zeigerX = this.getX(); int zeigerY = this.getY(); TaskField tf = (TaskField)taskworld.getObjectsAt(zeigerX, zeigerY, TaskField.class).get(0); this.setLocation(tf.getX(), tf.getY()); if (this.getVocabID() == tf.getTaskFieldVocabID()) { this.setVocabStatusRight(); } else { this.setVocabStatusWrong(); } } return; } }