This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

MrCohen
MrCohen presents ...

2020/6/10

Image Load vs Cache

Caching means loading data from the computer's storage device (SLOW) to the computer's memory/RAM (FAST) so that the game can be as smooth as possible.

Elephant demonstrates proper caching - the GreenfootImages are all loaded in the World's constructor and loaded before the user presses play. Elephant2, on the other hand, loads images each time it needs one, and is a lot more resource intensive.

While the difference is not evident in this simplified scenario, the performance difference is significant, and this will start to make a big difference once your program increases in complexity.

1340 views / 22 in the last 7 days

1 vote | 0 in the last 7 days

Tags: with-source

open in greenfoot
Your browser is ignoring the <APPLET> tag.

No Comments

Want to leave a comment? You must first log in.

Who likes this?

SwaggyXiao