Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9045013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:08:27+00:00 2026-06-16T11:08:27+00:00

I am making a game with dices with HTML 5 and JS. Now I

  • 0

I am making a game with dices with HTML 5 and JS. Now I need to preload the dice images. I am using preloadJS library. So my question is how can i preload two or more manifests without writing the same code for every dice? Please see my example.

My manifest files are: dice_twos, dice_threes, dice_fours, dice_fives, dice_sixes.
*I have 50 images for one dice*

var n=0;
var diceRegX = 45;//X registration point for dice 
var diceRegY = 45;//Y registration point for dice 

for(var i=0; i<50;i++){
    dice_twos.push({ src: "Assets/DiceImages/ONE_Main." + i + ".png", id: "dice" + i, reelImg: false });
    dice_threes.push({ src: "Assets/DiceImages/ONE_Main." + i + ".png", id: "dice" + i, reelImg: false });
    dice_fours.push({ src: "Assets/DiceImages/ONE_Main." + i + ".png", id: "dice" + i, reelImg: false });
    dice_fives.push({ src: "Assets/DiceImages/ONE_Main." + i + ".png", id: "dice" + i, reelImg: false });
    dice_sixes.push({ src: "Assets/DiceImages/ONE_Main." + i + ".png", id: "dice" + i, reelImg: false });
}
preload = new createjs.PreloadJS();
preload.onFileLoad = handleFileLoad;
preload.onProgress = handleOverallProgress;
preload.onFileProgress = handleFileProgress;
preload.onError = handleFileError;

function stop() {
    if (preload != null) {
        preload.close();
    }
}

function loadAll() {
    while (dice_twos.length > 0) {
        loadAnother();
    }
}

function loadAnother() {
    var item1 = dice_twos.shift();
    handleFileLoad(item1);
}

// File complete handler 
function handleFileLoad(event1) {
    dice_1[n] = new createjs.Bitmap(event1.src);
    dice_1[n].name = ('dice' + (n + 1));
    dice_1[n].regX = (diceRegX - 5);
    dice_1[n].regY = (diceRegY - 5);
    dice_1[n].x = (canvas.width + 80);
    dice_1[n].y = (canvas.height / 2);
    n++;
}

I was trying to pass another argument to handleFileLoad function but doesn’t seems to work. Any help will be appreciated. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:08:28+00:00Added an answer on June 16, 2026 at 11:08 am

    Hi guys Here is the solution of that what I need. I hope that this will help someone… Cheers

    var dice_twos = new Array();
            var dice_threes = new Array();
            var dice_fours = new Array();
            var dice_fives = new Array();
            var dice_sixes = new Array();   
            var dice_1 = new Array();
            var dice_2 = new Array();
            var dice_3 = new Array();
            var dice_4 = new Array();
            var dice_5 = new Array();
            var dice_6 = new Array();
            var i = 0;
            var n = 0;
            var item1;
            var item2;
            var item3;
            var item4;
            var item5;
            var item6;
    
         for (var i = 1; i <= 50; i++) {
                            dice_twos.push({ src: "Assets/DiceImages/TWO_Main." + i + ".png", id: "dice" + i, reelImg: false });
                            dice_threes.push({ src: "Assets/DiceImages/THREE_Main." + i + ".png", id: "dice" + i, reelImg: false });
                            dice_fours.push({ src: "Assets/DiceImages/FOUR_Main." + i + ".png", id: "dice" + i, reelImg: false });
                            dice_fives.push({ src: "Assets/DiceImages/FIVE_Main." + i + ".png", id: "dice" + i, reelImg: false });
                            dice_sixes.push({ src: "Assets/DiceImages/SIX_Main." + i + ".png", id: "dice" + i, reelImg: false });
                        }
                }
                // Create a preloader. There is no manfest added to it up-front, we will add items on-demand.
                preload = new createjs.PreloadJS();
                preload.onFileLoad = handleFileLoad;
                preload.setMaxConnections(5);
                loadAll();
            }
    
            function stop() {
                if (preload != null) { preload.close(); alert("preloader closed..."); }
            }
            function loadAll() {
                while (dice_ones.length > 0) {
                    loadAnother();
                }
            }
            function loadAnother() {
                // Get the next manifest item, and load it
                item1 = dice_ones.shift();
                item2 = dice_twos.shift();
                item3 = dice_threes.shift();
                item4 = dice_fours.shift();
                item5 = dice_fives.shift();
                item6 = dice_sixes.shift();
                handleFileLoad(item1);
    
            }
            // File complete handler
            function handleFileLoad(event1) {
                dice_1[n] = new createjs.Bitmap(event1.src);
                dice_1[n].name = ('dice' + (n + 1));
                dice_1[n].regX = (diceRegX - 5);
                dice_1[n].regY = (diceRegY - 5);
                dice_1[n].x = (canvas.width + 80);
                dice_1[n].y = (canvas.height / 2);
                dice_1[n].in_holder = (-1);
    
                dice_2[n] = new createjs.Bitmap(item2.src);
                dice_2[n].name = ('dice' + (n + 1));
                dice_2[n].regX = (diceRegX - 5);
                dice_2[n].regY = (diceRegY - 5);
                dice_2[n].x = (canvas.width + 80);
                dice_2[n].y = (canvas.height / 2);
                dice_2[n].in_holder = (-1);
    
                dice_3[n] = new createjs.Bitmap(item3.src);
                dice_3[n].name = ('dice' + (n + 1));
                dice_3[n].regX = (diceRegX - 5);
                dice_3[n].regY = (diceRegY - 5);
                dice_3[n].x = (canvas.width + 80);
                dice_3[n].y = (canvas.height / 2);
                dice_3[n].in_holder = (-1);
    
                dice_4[n] = new createjs.Bitmap(item4.src);
                dice_4[n].name = ('dice' + (n + 1));
                dice_4[n].regX = (diceRegX - 5);
                dice_4[n].regY = (diceRegY - 5);
                dice_4[n].x = (canvas.width + 80);
                dice_4[n].y = (canvas.height / 2);
                dice_4[n].in_holder = (-1);
    
                dice_5[n] = new createjs.Bitmap(item5.src);
                dice_5[n].name = ('dice' + (n + 1));
                dice_5[n].regX = (diceRegX - 5);
                dice_5[n].regY = (diceRegY - 5);
                dice_5[n].x = (canvas.width + 80);
                dice_5[n].y = (canvas.height / 2);
                dice_5[n].in_holder = (-1);
    
                dice_6[n] = new createjs.Bitmap(item6.src);
                dice_6[n].name = ('dice' + (n + 1));
                dice_6[n].regX = (diceRegX - 5);
                dice_6[n].regY = (diceRegY - 5);
                dice_6[n].x = (canvas.width + 80);
                dice_6[n].y = (canvas.height / 2);
                dice_6[n].in_holder = (-1);
                n++;                
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a Yahtzee-like (a dice game with scoring) in c++ using SDL. It's
okay i'm making a game using c++ (for the engine) and openGL, now i've
I'm making a game with my friend. Now there is a question about levels.
I'm making a game in Java where I need dices. There are 3 dices
I am making game and need to prepare view for level selection. Could you
I'm making a game for the Android platform and I need to access some
I am making a game engine using HTML5 canvas, and I have decided to
I'm making a game in Ruby on Rails as a school project but now
I am now making a game where at first the player will see the
I'm making a game with Three.js, and I need to get user input. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.