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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:01:22+00:00 2026-06-14T03:01:22+00:00

EDIT I’d still like to know why this happened but after reading some stuff

  • 0

EDIT
I’d still like to know why this happened but after reading some stuff on prototypes my solution was to not let the 2 objects override the base prototype as according to this http://freshbrewedcode.com/derekgreer/2011/12/31/solid-javascript-the-liskov-substitution-principle/

I have 3 objects

the base object is called the object control

object moneyBag and object movementPad both inherit controls’ prototypes.

both money bag and movementPad have 2 different draw Functions so the code looks like this

Money.prototype.Draw = function (context) {
    console.log("foo2");
}

MovementPad.prototype.Draw = function (context) {
    console.log("foo1");
}

in my HUD.js both these objects are initalized, Hud then calls these 2 objects draw like so

var movementControl = new MovementPad(screenManager, 1,1,1,1);

var money = new Money(screenManager, 10, 10, 37, 36);

   // .... code skipped
this.Draw = function (context) {
    movementControl.Draw(context);
    money.Draw(context);
}

my issue is both of these objects are not calling their draw method. If I initialize movementPad first then that draw method will be called, if I initialize money first only that draw method will be called.

What am I miss understanding/doing wrong with prototypes for both of their draw methods to not be called.

(more code below)

function control(x, y, width, height) {
    "use strict"
    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;

    var defaultImg = new Image();
    defaultImg.src = "blank.png";
}


    //.... code skipped

control.prototype.Draw = function (context) {
    context.drawImage(defaultImg, this.x, this.y, this.width, this.height);
}

movementPad.js

MovementPad.prototype = control.prototype;
MovementPad.prototype.constructor = MovementPad;

function MovementPad(screenManager, x, y, width, height) {
    "use strict"
    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;

    //.... code skipped

    MovementPad.prototype.Draw = function (context) {
        context.drawImage(movementPad, x, y , width ,height);

    }

}

Money.js

Money.prototype = control.prototype;
Money.prototype.constructor = Money;

function Money(screenManager, x, y, width, height) {
    "use strict"
    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;

  //.... code skipped

    Money.prototype.Draw = function (context) {
        context.drawImage(moneyBag, x, y, width, height);
    }
}
  • 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-14T03:01:24+00:00Added an answer on June 14, 2026 at 3:01 am

    You’ve assigned the same instance of control.prototype to both Money and MovementPad‘s prototypes, so your Draw method declarations are clobbering eachother.

    Make the prototypes separate instances:

    Money.prototype = new control();
    // ...
    MovementPad.prototype = new control();
    

    and your Draw assignments should work.

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

Sidebar

Related Questions

Edit: I think I figured out the solution, but I'm still interested to know
EDIT After staring at this for 2 days, I do see one issue. I
EDIT:This did it: SELECT DISTINCT profileid FROM profilesrelevation WHERE profileid NOT IN ( SELECT
EDIT I don't know is it important, but destination triangle angles may be different
EDIT: for those who come here with a similar problem, now i know this
EDIT: I'd like to get a definitive answer on whether or not it's possible
Edit: I'm looking for solution for this question now also with other programming languages.
EDIT Leaving this for posterity, but nearly a year later, to get down voted,
edit: change of question if my code is like this: <form name=login action=https://login.extremebb.net/login method=post
EDIT: Ive edited my code a little thanks to Alexander's advice, but im still

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.