I wanted to know if there is a function, some library or anything that facilitates the preloading of images. Does requirejs work for this? I'm doing so at the moment:
var imgs = [];
imgs["cartas"] = [];
imgs["cartas"]["ouros"] = [];
imgs["cartas"]["espadas"] = [];
imgs["cartas"]["copas"] = [];
imgs["cartas"]["paus"] = [];
imgs["cartas"]["versos"] = [];
imgs["cartas"]["versos"]["azul"] = [];
imgs["cartas"]["versos"]["verde"] = [];
imgs["cartas"]["versos"]["vermelho"] = [];
for (var i = 0; i < 10; i++) {
imgs["cartas"]["ouros"].push(loadImg('img/cartas/ouros/carta${i}.png'));
imgs["cartas"]["espadas"].push(loadImg('img/cartas/espadas/carta${i}.png'));
imgs["cartas"]["copas"].push(loadImg('img/cartas/copas/carta${i}.png'));
imgs["cartas"]["paus"].push(loadImg('img/cartas/paus/carta${i}.png'));
if (i > 0 && i < 6) {
imgs["cartas"]["versos"]["azul"].push(loadImg('img/cartas/versos/azul${i}.png'));
imgs["cartas"]["versos"]["verde"].push(loadImg('img/cartas/versos/verde${i}.png'));
imgs["cartas"]["versos"]["vermelho"].push(loadImg('img/cartas/versos/vermelho${i}.png'));
}
}