Report as inappropriate.
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.
Want to leave a comment? You must first log in.
No Comments