DrawText in RMMV

So I was using the good ol' draw_text function in VX Ace and am trying to use it again in MV, but I can't seem to find any examples of using it outside of a menu.

Literally, just want to draw the words "Draw Text" at 1,230 and it works perfectly in VX Ace.
Code from VX Ace:

Ruby:
@sprite = Sprite.new
@sprite.bitmap = Bitmap.new(200, 16)
rect = Rect.new(0, 0, 200, 16)
text = "Draw Text"
@sprite.x = 1
@sprite.y = 230
@sprite.bitmap.draw_text(rect, text)

Sadly I'm at a loss as to how to do this in Javascript aside from what I've tried since I can't find the script editor like before.

JavaScript:
Game_Interpreter.prototype.testDraw = function(){
var text = "Draw Text";
var sprite = this.Sprite();
this.drawText(text,172,5);
this.update();
};

and calling it with

myPlugin.testDraw();

Now I'm pretty sure I'm missing the rectangle that contains the bitmap for drawing the text so if anyone can help, it would be appreciated!
Nobody?
drawing a text on the map itself require the Game_Map part, but I cannot tell exacly
how or where (still learning).

there are functions to use, but JS require sometimes more function to get something.
it depends for what reason you need to use it and where (always visible, temporarly, etc)
to push you to the right directtion.

if it's something like lables, there are plugins for those already to look at, you can
also event it in a little scriptcall, if it need to stay fixed in a corner or whatever, there
is also a plugin to make it easier, but it's a big plugin.

so there are some ways we need to know what exact purpose it is what you seek
so we dont have to gues around which approach you need.

I've moved this thread to Learning Javascript. Thank you.


How do you plan on drawing the text? The drawText method originally comes from the Bitmap object. It's still there in MV/MZ:
Code:
Bitmap.prototype.drawText = function(text, x, y, maxWidth, lineHeight, align) {
    // [Note] Different browser makes different rendering with
    //   textBaseline == 'top'. So we use 'alphabetic' here.
    const context = this.context;
    const alpha = context.globalAlpha;
    maxWidth = maxWidth || 0xffffffff;
    let tx = x;
    let ty = Math.round(y + lineHeight / 2 + this.fontSize * 0.35);
    if (align === "center") {
        tx += maxWidth / 2;
    }
    if (align === "right") {
        tx += maxWidth;
    }
    context.save();
    context.font = this._makeFontNameText();
    context.textAlign = align;
    context.textBaseline = "alphabetic";
    context.globalAlpha = 1;
    this._drawTextOutline(text, tx, ty, maxWidth);
    context.globalAlpha = alpha;
    this._drawTextBody(text, tx, ty, maxWidth);
    context.restore();
    this._baseTexture.update();
};
So basically, I'm trying just to draw a very simple HUD which is literally just listing some stats that get updated every "turn" in combat. Here is a screenshot of what it looks like it VXA:
1206854854_preview_SARASS2.png

Literally, just 8 lines of text on each side of the screen...

I think what I may be doing is overcomplicating how to draw text. So does that mean I can literally just do:

this.drawText("Hello World", 0, 0, 200, 20, "left")

to draw "Hello World" in the upper left corner of the screen?
The drawText function comes from the Bitmap object, so you can't just use it anywhere. Usually people draw stuff like that inside windows. You can just create windows and make them transparent. If you just call this.drawText() inside a game object it's going to throw you an error telling you that drawText is not defined.
The drawText function comes from the Bitmap object, so you can't just use it anywhere. Usually people draw stuff like that inside windows. You can just create windows and make them transparent. If you just call this.drawText() inside a game object it's going to throw you an error telling you that drawText is not defined.
Ok, I'll try attaching it to an invisible window.

I did finally fix the HUD in VXAce so I might try and convert that first now that I'm starting to get the hang of Javascript. (Even though I still hate it) It sucks letting a project sit for 2 years and suddenly regaining that inspiration to try and finish it.

Original thread: https://forums.rpgmakerweb.com/threads/drawtext-in-rmmv.131952/