hm, what would be the bug ? Synch issues?
Heya.
Well, i tried loading using the method you described and .getTexture();
But it gave some bugs and the image didnt show up. Thought no errors.
Also, after i loaded the missile texture , my method collision kept telling it was happening collisions all the time;
Would you give me another hand please
This is how the class is :
It returns an AtlasRegion. I guess you can cast it to TextureRegion…
You should call Atlas.generateAtlas() in the show() or create() method first.
Assuming you want to call it from a class which extends Game;
public void create() {
Atlas.generateAtlas();
setScreen(new MyWorld());
}
Then, because you created and loaded the atlas, you can get any image like this:
AtlasRegion planeImage = Atlas.get("plane");
Notice that the guy who helped me packed the atlas in the runtime. We also can prepare the atlas first and get AtlasRegions from it later in the game. Probably preparing it beforehand is more efficient.
But this way, if you decide to have another image in the atlas, or want to change one of the images, it is easier.
If it is necessary to use a TextureRegion, you can just cast it:
TextureRegion text = (TextureRegion) planeImage;
But I am not sure if this is efficient or right thing to do.
BTW, Rectangle has a method to detect intersections. Assume planeBounds and missileBounds are two rectangles. You can do that:
planeBounds.overlaps(missileBounds);
This returns true or false.
public class BadForLoopRemoval {
public static void main(String[] args) {
List<String> items = new ArrayList<String>();
items.add("a");
items.add("b");
items.add("c");
items.add("d");
items.add("e");
for (int i = 0; i < items.size(); i++) {
String item = items.get(i);
System.out.println(item);
if (item.equals("c")) {
// items.remove(item);
items.remove(i);
}
}
}
}