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

Report as inappropriate.

MrCohen presents ...


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.

751 views / 397 in the last 7 days

1 vote | 0 in the last 7 days

Tags: with-source

open in greenfoot
Your browser does not support the canvas tag.

No Comments

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

Who likes this?