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 8380383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:26:40+00:00 2026-06-09T16:26:40+00:00

I am creating a simple game with HTML5 and JavaScript. Initially when the Game

  • 0

I am creating a simple game with HTML5 and JavaScript.

Initially when the Game starts it takes some time to load images and sound.
During this time the user has to wait and the screen looks unpleasant.

So here’s what i want to do

  1. Check loading status of images and sound.

  2. Increase % of loading as and when resources are loaded and respectively increase progress bar.

I really don’t have any key from where to start. Please Guide me through.

  • 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-09T16:26:42+00:00Added an answer on June 9, 2026 at 4:26 pm

    Monitoring load status for all loading items can be daunting, but, in a nutshell, the best way to go about it is to do the following:

    • First, add to a totalResources counter, so the game knows how many resources to expect.

    • Add eventListeners to the loading resources, and add to a loadingResources counter. If it loads successfully or fails, add to the loadingResources counter.

    • Once the counters are equal, either all the resources loaded, or there were some errors in loading certain files.

    The catch with this method is, on rare occasions, the loadingResources can match the totalResources variable prematurely. You can fix this by making a flag that checks to see if all the resources that needed to load have started loading already.

    Now, depending on how you make your game, a failed resource load shouldn’t really stop the game from working. For example, if a sound doesn’t load properly, it just won’t play. You might want to retry or abort if a resource needs to load.

    As for a % based loading, that’s a bit iffy. The HTML5 spec includes a progress bar, but for multiple resources, your best bet might just be a bar that fills up as resources are loaded.

    Addendum:

    Sound files are a huge pain to load, and I’ve had little success perfecting it across all browsers. Here’s how I went about it:

    1. First, don’t rely on the load() function to invoke loading an audio element. Instead, force it to play, like so:

      sound.channels[i].volume = 0;

      sound.channels[i].play();

      (Also, to replay a sound, set the duration to a near 0 value when the sound is paused.)

    2. As to allow multiple sounds to play at the same time, it is good practice to have multiple audio elements (thus the channels array above). However, you don’t need to wait for all the sound channels to load. Once one loads, clone the node and force a silent play again to avoid any delays.

    3. It’s anecdotally more reliable to use the canplaythrough event callback to see if a sound is ready. If a sound fails to load, use the error callback. The problem is that there are a number of errors that can cause a sound file to fail to load.

    4. Don’t forget to use <source> elements to allow for multiple audio formats.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a simple RPG game, first time using XNA. Trying to get my character
I'm creating a simple JavaScript multiple choice game. Here is a sample question: p
I'm creating a simple 2D game in javascript/canvas. I need to figure out the
I am creating a simple Sudoku game. Since this is my first big i
I'm creating a simple matching game for kids for iPad. All images are drawn
I am creating a simple game database and I am having some problems. There
I'm creating a simple 2D game in java. I've only done this in C++
I am new to XNA, and I am creating a simple game. Sorry that
I'm creating a simple labyrinth game with Java + Swing. The game draws a
I am creating a simple tennis game in Objective-C. Currently, when the player or

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.