MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / loadAssets

Function loadAssets

assets/js/8_ball_pool/Tools.js:16–39  ·  view source on GitHub ↗
(callback)

Source from the content-addressed store, hash-verified

14}
15
16function loadAssets(callback)
17{
18 function loadSprite(fileName)
19 {
20 assetsStillLoading++; //increasing the quantity of loading tools
21
22 let spriteImage = new Image();
23 spriteImage.src = "../assets/Images/8_ball_pool/" + fileName; //file source
24
25 spriteImage.onload = function()
26 {
27 assetsStillLoading--; //when all tools stops loading then start decreasing it
28 }
29 return spriteImage;
30 }
31 sprites.background = loadSprite('table.png'); //for loading pool table
32 sprites.stick = loadSprite('stick.png'); //for loading cue stick
33 sprites.whiteBall = loadSprite('white_ball.png'); //for loading cue ball
34 sprites.yellowBall = loadSprite('yellow_ball.png');
35 sprites.redBall = loadSprite('red_ball.png');
36 sprites.blackBall = loadSprite('black_ball.png');
37
38 assetsLoadingLoop(callback); //it shows image only when all images get loaded
39}
40
41function getBallSpriteByColor(color)
42{

Callers

nothing calls this directly

Calls 2

loadSpriteFunction · 0.85
assetsLoadingLoopFunction · 0.85

Tested by

no test coverage detected