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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:08:36+00:00 2026-06-05T12:08:36+00:00

I am working on an HTML5 Canvas game, and the level needs to pre-load

  • 0

I am working on an HTML5 Canvas game, and the level needs to pre-load some images (and eventually other data such as audio files, too). I am planning on having all of these images stored in an array, or a container object. What I need to do is find a way to wait until all of these images are downloaded completely before continuing in the game.

This does NOT happen when the page is opened. This happens deep within the running script, and the images are dynamically loaded. The idea is to display a “loading” message, and once everything is done, start the level as intended.

I have access to jQuery, but I would prefer to stick with straight Javascript code. Does the window.onload function work here since it’s not actually happening when the page loads? If no such event exists, is there a way to traverse through image objects and check if they’re loaded yet?

  • 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-05T12:08:37+00:00Added an answer on June 5, 2026 at 12:08 pm

    You can have a counter to check in the onload event if all the images load(or failed).
    Something like

    var loadedImages = 0;
    var failedImages = 0;
    var imageCount = amount of images
    function loaded(){
        loadedImages++;
        if (loadedImages == imageCount){
            //all images successfully loaded
        }
        else if ((loadedImages+failedImages) == imageCount){
            //all images completed
        }
    }
    function failed(){
        failedImages++;
        if ((loadedImages+failedImages) == imageCount){
            //all images completed
        }
    }
    var images = array();
    for (var i = 0; i < imageCount; i++){
        images[i].onload = loaded;
        images[i].onerror = failed;
        images[i].src = the image source
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a CoffeeScript game engine for Html5 canvas. I came up
I'm working on a html5 canvas game, but I don't know how to handle
I'm working on a HTML5 canvas game using a JavaScript library called Propulsionjs.com. The
I am working on a simple platform game in HTML5/Canvas/Javascript/jQuery. You can see it
Yo everyone! I have been working on an Isometric Tile Game Engine in HTML5/Canvas
I'm working on a simple JavaScript game using HTML5 canvas. It's a very typical
Working on a small game using an HTML5 canvas, and javascript. And it's working
I have a small project I am working on HTML5 canvas and I wanted
I'm working with the HTML5 canvas element. Let's say I have 2 ImageData objects
OK, so I have created an HTML5 canvas game that uses localStorage. I have

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.