简体   繁体   中英

(Java) Best way to display images?

I've been making a game for a while now, but its a bit slow and clunky. I was wondering if this had to do with the way I drew images on the screen. I stored individual sprites as BufferedImages and displayed them on a canvas, and redrew them when I needed to. My question is is there a better way to draw sprites? I feel as though having to redraw every BufferedImage when the player moves around is not efficient, and there has to be more clever ways of drawing graphics.

I have had similar issues with run time speeds. What I did was reduce the number of times my program redrew to the screen. I used the Thread.sleep(int) method to accomplish this. By doing this it only drew to the screen a specified amount of times, rather than approximately 1000 times/sec.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM