swing - Blank picture layers not resetting properly Java -


currently, i'm trying make panel management of clips in game i'm writing. when player clicks mouse, highlight clips shown @ right of screen, , if player presses h on keyboard, show onscreen few bullets player. when draw these strings, draw big gray square , text in black on top of it. when try clear (by resetting image drawn onto blank image source files) of new things drawn on top of screen instead of screen being cleared away.

public void refresh(){         overimg = world.imagebank.getimage("blank", -1).getsubimage(0, 0, 400, 400);     drawinfo();         drawclips();         drawlayers();         repaint();     } 

the imagebank sounds like, bank of images drawn in when world initialized. getimage("blank", -1) returns 1200, 1200 image made has blank alpha channel, , use smaller version of it. refresh method called every time pressed, , can't understand why image isn't reset. if there other code should provide might problem, let me know.

for else runs same problem, friend showed me solution. when pull in image image bank, isn't making new image(which should have been obvious), giving reference subimage portion of original, means drawing onto blank buffered image stored in image bank. should done prevent making deep copy of image, needs done (more or less) this.

public static bufferedimage deepcopyimage(bufferedimage bf){         colormodel cm = bf.getcolormodel();         boolean alphapre = bf.isalphapremultiplied();         writableraster wr = bf.copydata(null);         return new bufferedimage(cm, wr, alphapre, null);     } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -