Hi! In my current story, the background image shifts with some of the passages. E.g. When you're in a cottage, there's a cottage background, then in a forest there's a forest etc.
I'm looking for a way to preload these images to minimize on players arriving on a black-screen background.
I found this chunk of Javascript code on one of the threads, but it was talking about Harlowe, not SugarCube 2.0. Just checking to see if it's applicable, or I need another solution to the problem. CSS I get, but Javascript does my head in.
I'm looking for a way to preload these images to minimize on players arriving on a black-screen background.
I found this chunk of Javascript code on one of the threads, but it was talking about Harlowe, not SugarCube 2.0. Just checking to see if it's applicable, or I need another solution to the problem. CSS I get, but Javascript does my head in.
(function() { var images = []; var preload = [ "urlofimage1", "urlofimage2", "urlofimage3" ]; for (var i = 0; i < preload.length; i++) { images[i] = new Image(); images[i].src = preload[i]; } })();