java - How to get link from Array<T> level? -
how object reference(link) object array(levelarray)? f.e., levelarray has created object "level1" under index 1, , need change variables in object. how it?
public class leveleditorscreen implements screen { final drop game; private batch batch; private array<level> levelarray; private int levelcount; private void createlevel(int lvlcount) { levelcount += 1; lvlcount = levelcount; levelarray.add(new level()); } }
if know index can use get(int index)
method.
levelarray.get(0); //this return object of index 0
if don't know index, know variable set specific value can desired object:
in example level
has variable string name
for(level level : levelarray) { if(level.name.equals("awesome level")) { //we found desired level! } }
Comments
Post a Comment