Hi there,
I have the following code lines in my JavaScript code:
[CODE]var colors = [“#F08”, “#0B8”, “#04F”, “#FD0”, “#808”, “#F20”];
This sets the bg colors of my divs. This var is only used here:
[CODE]function activateItems(callback) {
var itemsActivated = false;
for (var i=0;i<cfg.rows;++i) for (var j=0; j<cfg.cols; ++j) {
var item = itemAt(i,j);
if(!item) continue;
if (item.deleted>0) {
item.style.background=colors[Math.floor(Math.random()*colors.length)];
itemsActivated = true;
}
}
if (itemsActivated)
animateAppear(callback ? callback : findPatterns);
}
and here:
[CODE]function animateDecor() {
if(state == ‘init’ || state == ‘game’) return;
for (var i=0;i<cfg.rows;++i) for (var j=0;j<cfg.cols;++j) {
var item = document.getElementById(“decor_”+i+”_”+j)
if(!item) continue;
item.style.background=colors[Math.floor(Math.random()*colors.length)];
}
animation = setTimeout(animateDecor, 120);
}
This all works great, only I don’t want to use hex (#) colors as background, I want to use images. These are located for example in: images/blue.png, images/red.png, etc. But how to pull this off? Tried several stuff including backgroundImage:url and so, but these where unsuccessful. I am just starting to learn this so some corrected code examples with comments will really help.
I think the solution is very simple, but I just don’t see it (yet)…
Many thanks