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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:36:33+00:00 2026-06-08T18:36:33+00:00

I am working on HTML 5 Canvas game, with a gameloop. Here is my

  • 0

I am working on HTML 5 Canvas game, with a gameloop.

Here is my code so far. It doesn’t do anything and that is fine, but I am getting an error

TypeError: Object [object DOMWindow] has no method ‘Update’ [http://localhost:2516/scripts/lib/Game.js:47]

Edit: This code works, it no longer reflects the problem, it reflects the solution

  var game;
    var Game = function () {
    }


   Game.prototype.Update = function () {

}

Game.prototype.Draw = function () {

}

function GameLoop () {


    game.Update(); //this is line 47
    //context.save();
    game.Draw();
   // context.restore();
    setTimeout(GameLoop, 10);
}
function Start() {
    game = new Game();
   GameLoop();
}

Edit: I think the “this” is looking at the document instead of the Game object, which I don’t understand why or how to fix it

  • 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-08T18:36:36+00:00Added an answer on June 8, 2026 at 6:36 pm

    The issue is likely with this line within GameLoop:

    setTimeout(this.GameLoop, 10);
    

    You can’t pass a “method” reference; only function references. So, when this is called by setTimeout, it will be called without a set context, like you’d called it as:

    GameLoop();
    

    You have to either bind it:

    setTimeout(this.GameLoop.bind(this), 10);
    

    Or wrap it in another function similar to what bind will do (saving this as self as the function will have its own value for this):

    var self = this;
    // ...
    setTimeout(function () {
        self.GameLoop();
    }, 10);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

some html codes are not working on my IE8, but works fine on firefox.
I'm working on an HTML class in PHP, so that we can keep all
I am currently working on a html file that prompts you to enter a
I'm currently working on a pure html 5 canvas implementation of the flying tag
Here's my code. I created a VIBGOYR pattern on the canvas and want to
Here is my html: <canvas id=test width=400 height=200></canvas> here is my javascript: var canvas_one
I have this code and in Firefox is working well, but in Chrome I'am
I working on HTML Canvas library to construct a PIE Chart Now to finish
Yo everyone! I have been working on an Isometric Tile Game Engine in HTML5/Canvas
While working on HTML, CSS (and more) like changing the code and refreshing the

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.