MV this.drawCharacter does not draw character graphic

Hi all,

I have an issue with the Window_Base this.drawCharacter() method. For some reason when I call this method in the initialize function of my custom window, it doesn't draw the character graphic.

For context, this is basically a fresh project. The this.drawText(), this.drawTextEx() and this.drawIcon() methods all successfully draw what they're supposed to. It seems like it's only the this.drawCharacter() method that does not work.

1630151346228.png

Here's my code for reference. Please note I'm using ES6-style classes.
Is this a caching issue? If so, how do I fix it?

Thanks in advance for any responses!
Removed.
Images are loaded via XHR (asynchronous) but drawCharacter, a blit/paint type method, assumes the image data is already in memory. Some possible approaches:
  1. Set up a check (e.g. if (ImageManager.isReady())) in an appropriate method of the window (e.g. update) before blitting the image. You can use a flag to avoid drawing the image more than once, e.g. set this._refreshRequested = true on init, check that before the "image ready" check, and delete the flag once the image is drawn.

  2. Attach a load listener to the Bitmap, e.g. (untested):
    JavaScript:
    initialize(x, y, width, height) {
      super.initalize(x, y, width, height);
      const bmp = ImageManager.loadCharacter('hazmat');
      bmp.addLoadListener(this.drawMe.bind(this));
      // etc
    }
    
    drawMe(bmp) {
      this.drawCharacter('hazmat', 0, 30, 0);
    }

  3. Use a Sprite instance, added to the window's background contents. This is more memory intensive but lets the image refresh itself when its source loads, and remain its own entity for more control.
(RMMV's Bitmap and Sprite wrappers are defined in rpg_core.js.)

Also, in case you plan to share this code with others: note that RMMV's playtest/deployment environment used ES5 up until a certain version (I think v1.6.0).

Original thread: https://forums.rpgmakerweb.com/threads/this-drawcharacter-does-not-draw-character-graphic.139957/