We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Or I'm retarded, I'll let you be the judge.
lightObjects.add(new LightObject(round((mouseX - objectWidth/2)/25) * 25.0,round((mouseY - objectWidth/2)/25) * 25.0,1));
lightObjects.add(new LightObject(round((mouseX - objectWidth/2)/25) * 25.0,round((mouseY - objectWidth/2)/25) * 25.0,2));
println(lightObjects);
lightObjects.remove(new LightObject(round((mouseX - objectWidth/2)/25) * 25.0,round((mouseY - objectWidth/2)/25) * 25.0,1));
println(lightObjects);
returns:
[luminous$LightObject@448dbd82, luminous$LightObject@3594c4f7, luminous$LightObject@3a0f4f9c]
[luminous$LightObject@448dbd82, luminous$LightObject@3594c4f7, luminous$LightObject@3a0f4f9c]
Answers
Perhaps you should try to remove() by index? :-&
You try to remove an object that is not in the list, since you create a new one in the remove() call!
Unless your LightObjects redefines the equals() method, of course. But anyway, it is an inefficient way to do it, better use index, as said.
Thanks for the comments. I have redefined equals() since I don't want to loop through the arraylist to check for equality. An updated code sample can be found:
http://www.reddit.com/r/processing/comments/1qxmti/arraylistremove_not_working_as_expected/