alaios
08-26-2002, 05:42 PM
I have this game
http://www.geocities.com/alaios2/match/
i want to preload all the images before the player can do any selection....What can i do?
beetle
08-26-2002, 05:50 PM
Uhhh, maybe adding this will do it for (var t = 1; t <= tiles; t++) {
tile[((s-1)*tiles)+t] = new Image()
tile[((s-1)*tiles)+t].src = 'images/'+s+'_'+t+'.gif';
}
alaios
08-26-2002, 06:26 PM
xmmm no thankes..this does not work as i want....
duniyadnd
08-26-2002, 08:59 PM
Try creating an array of the images in your head tag and running through them, as a function, and call that function in your body tag
<body onload="preloadimages();">
It should preload the images, just take a longer time to open the page initially.
Duniyadnd
adios
08-27-2002, 02:31 AM
Try changing:
var notloaded=true;
..to:
var unloaded=0;
Then:
unloaded = tiles * sets + 1;
for (var t = 1; t <= tiles; t++) {
tile[((s-1)*tiles)+t] = new Image();
tile[((s-1)*tiles)+t].onload = function() {--unloaded};
tile[((s-1)*tiles)+t].src = 'images/'+s+'_'+t+'.gif';
}
Then:
function select(pos) {
if (unloaded) return;