1 decade ago by Joncom
Just thinking out loud, but any input or feedback would be great too!
I'd like to add an options/settings menu to a game, and a "scale" setting would be nice.
What considerations must be made to change the scale on-the-fly, after the game has initialized?
1. A copy of the original 1x image must be kept because it would be used to generate all non-1x scaled images.
2. After changing the scale, loop through images in
3.
4. Consider using
I'd like to add an options/settings menu to a game, and a "scale" setting would be nice.
What considerations must be made to change the scale on-the-fly, after the game has initialized?
1. A copy of the original 1x image must be kept because it would be used to generate all non-1x scaled images.
2. After changing the scale, loop through images in
ig.Image.cache
and call .resize
for any image which does not have a current scale version of itself in cache.3.
.resize
must use the original 1x image version mentioned in step 1, not the scaled version.4. Consider using
localStorage
or some other local file storage method to cache scaled images, especially larger ones, because scaling is a CPU intensive task and can cause a particularly noticeable delay if the game is already running.