iponu777 Posted April 10, 2015 Share Posted April 10, 2015 So say i have a bird snare and i want to refer back to at that specific position.. How would i refer back to it later?? so like i want to be like birdSnareOrigin.interact("pickup"); but how would i declare that... Quote Link to comment Share on other sites More sharing options...
Lemons Posted April 10, 2015 Share Posted April 10, 2015 (edited) // Define this as a field, not local var! ArrayList<Position> mySnares = new ArrayList<Position>(); // Run this when you want to add a Position mySnares.add(theSnareEntity.getPosition()); // Run this when you want to retrieve a snare via its Position Entity mySnare = getObjects().closest(new NameFilter("Snare"), new PositionFilter(mySnares.get(snareIndex)); mySnares.remove(snareIndex); mySnare.interact("Pickup"); Edited April 10, 2015 by dudeami Quote Link to comment Share on other sites More sharing options...
Novak Posted April 10, 2015 Share Posted April 10, 2015 // Define this as a field, not local var! ArrayList<Position> mySnares = new ArrayList<Position>(); // Run this when you want to add a Position mySnares.add(theSnareEntity.getPosition()); // Run this when you want to retrieve a snare via its Position Entity mySnare = getObjects().closest(new NameFilter("Snare"), new PositionFilter(mySnares.get(snareIndex)); mySnares.remove(snareIndex); mySnare.interact("Pickup"); linked lists are usually better performance when doing a lot of adding/removing from the lists 1 Quote Link to comment Share on other sites More sharing options...
Botre Posted April 10, 2015 Share Posted April 10, 2015 linked lists are usually better performance when doing a lot of adding/removing from the lists Not something to worry about at this level :p Quote Link to comment Share on other sites More sharing options...
iponu777 Posted April 10, 2015 Author Share Posted April 10, 2015 (edited) Not something to worry about at this level I understand lists and stuff, just not the syntax or stuff like filters and some other stuff... my knowledge is limited to AP CS teachings,. Where just learning really about polymorphism, inheritance, and stuff like that for sub and super classes atm Edited April 10, 2015 by iponu777 Quote Link to comment Share on other sites More sharing options...