bufferstrategy - Java buffer strategy sometimes doesn't draw properly -
i created game in java uses buffer strategy. white frame or white border. happens every fifth time. searched lot can't figure out i'm doing wrong. code compiles , there aren't errors printed out.
if if fails, frame looks example that:
here's code (only relevant parts):
private bufferstrategy bs; public testclass(){ setresizable(false); setsize(1000,600); setdefaultcloseoperation(jframe.exit_on_close); setignorerepaint(true); setvisible(true); createbufferstrategy(2); bs = getbufferstrategy(); } protected void paint() { { graphics2d g=null; try { g = (graphics2d) bs.getdrawgraphics(); g.setcolor(color.cyan); g.fillrect(0, 0, this.getwidth(), this.getheight()); } { g.dispose(); } bs.show(); } while (bs.contentslost()); } public static void main(string[] args) { testclass window = new testclass(); window.paint(); }
Comments
Post a Comment