We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi!! I would like to have a nice "loading" animation at the start of my game, andd I dont know how to make a single variable to represent the complete loading of the files. I could write this for a single sound or image for example:
let sound1, able;
function setup(){
createCanvas(1000, 650);
able = false;
sound1 = loadSound("sound1.mp3", soundLoaded);
}
function soundLoaded(){
able = true;
}
function draw(){
if(!able){
loadinganimation();
} else { starGame(); }
}
But what if I need to load a Lot of images and sounds ? How can a I make that "able" variable true jsut at the end ? Helpp !! Thanks
Answers
How about some loading counter for it as well? *-:)
A more advanced loading screen approach via preload() +
id=p5_loading
: :ar!Why you did that ? What for ¿ It specify the length ?
I didnt know that it was posible.. I read the method with "id=p5_loading", and its cool, but I prefer to make my own animation . Thank you so much !!
done = ++loads === FILES;
is similar toif (++loads === FILES) done = true;
B/c the length of those 2 arrays is already pre-determined by their corresponding constants SOUNDS & IMAGES. :\">
And b/c instantiating a JS Array via a constructor is the closest on how we do in Java: ~O)
You can check the many ways to create JS arrays on these 2 links below: O:-)