bufferedimage - multiple instances of a class, loading images, make more efficient in java -


i making game has 100 bees chase , have sprites. when hit you, lose life. if hit 100, die , game resets. problem when resets, reloads images each bee. occurs 100 times , 2 pictures each, adds , creates severe delay.

this code images:

public void loadpic(){//open of images , store them in arraylist     string beedirectory="img/beeimgs/";     file folder = new file(beedirectory);     file[] listoffiles = folder.listfiles();      for(int i=0;i<listoffiles.length;i++){         beeimgs.add(new arraylist<bufferedimage>());     }      for(int h=0;h<listoffiles.length;h++){         file file=listoffiles[h];         if(file.isdirectory()){             try{                 file folder2=new file(beedirectory+file.getname()+"/");                 file[]listoffiles2=folder2.listfiles();                 (int = 0; < listoffiles2.length; i++){                     file file2 = listoffiles2[i];                     if (file2.isfile() && file2.getname().endswith(".png")){                             beeimgs.get(h).add(imageio.read(new file(beedirectory+file.getname()+"/"+file2.getname())));                     }                 }             }             catch(ioexception e){}         }     } } 

any appreciated.

thank you

just continue use original objects. create them 1 time when user hide them , re-position them @ start instead of getting rid of them , recreating. there should absolutely 0 delay.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -