MV [And RMMZ?] Quick Help (window+sprite = floating text)

So I understand the basic premise with windows and sprites, and I'm not sure if this should go in Plugin Development or here, but down to it:

The Situation:
I'm creating a survival needs plugin (You know: Hunger - thirst - fatigue - oxygen - sanity - radiation - temperature), and while the mechanics of it are going well and easy enough, I want to be able to do floating text above the actors' head's for some visual warning (besides a HUD that will be easier for me to do than just plain text for some reason).
Examples: *burp* (when drinking something) *stomach growls* (if hungry) *yawns* (if tired) and so on.

The Question:
Might be a multipart question to be more precise.
  1. Do I need to create a new window for the contents, or would a normal "new Bitmap" (like the game timer) work?
  2. How do I update its position to track on each actor? (Sprite_Character -> add child (so each actor has one)? or other?)
Keep in mind:
I am aware of some plugins already, like Yanfly's mini-label, or RMMZ's textPicture plugin, etc. The idea here is that I'm trying to keep this independent of other plugins.. and I have looked through some but I can't quite grasp/convert what they have to what I want. Just trying to get some perspectives out there.
If you're limiting yourself to basic functions, you can always use Balloons to show stuff up events heads. I think you can add more than the default ones, so not to be limited to 6 types
If you're limiting yourself to basic functions, you can always use Balloons to show stuff up events heads. I think you can add more than the default ones, so not to be limited to 6 types

You know I didn't even think about balloons... Could be fun to try, but still going to try to figure this out first. It's part of the plugin's original intent, so I want to stick to that for now (plus it's a learning experience)! 🙂 I'll definitely keep the balloons in mind for later though!
Not sure I understand what you mean by "trying to keep this independent of other plugins", but here are a couple you may find interesting (MV):
Otherwise, for coding it yourself:
  1. Window_Base has the advantage of a native drawTextEx method, in case you're interested in using text codes. Otherwise maybe consider a Sprite: it's a handy RPG-Maker wrapper for Bitmap. I recommend defining your own prototype/"class" for these floating text labels (e.g. Sprite_CharacterLabel), so that you can specify an update method for them.

  2. I don't think it matters much what parent you assign it, so long as you update its location when appropriate. Maybe:
    • Add them to the WindowLayer or Spriteset_Map instance as appropriate.
    • If the labels have their own update method, that should automatically be called each time the parent updates (typically every frame). You can use that to refresh the text/position when appropriate.
I simply meant that I want to script it myself, and not have to rely on other plugins to provide the effect. That said, however, I'll take a look at those two scripts to see how they did it for inspiration and see if I can't accomplish what I'm seeking.

I do have a new Sprite class setup, just wasn't sure where to assign it 🙂 Sprite_Character seemed appropriate at the time, but wasn't confident in that decision. First inspiration was from the Game_Timer (which seems to be created from Scene_Map update) which is just text(numbers).

I really appreciate the answer 🙂 I'll tinker with that for a bit and come back to report my results!
Hmm I have no clue what I'm doing. Tried semi-copying NASTY pop up text for testing, just to get something working. It... sorta showed up (half way), and trying to make the font smaller I think screwed up the algorithm. Then it didn't appear at all.

Tried doing same with TextPicture that comes with MZ but converting it over for MV and then I realized that's not going to work. It'll create a bitmap using Window_Base as a temporary measure, but then what... it's designed for a fixed image is it not? Or maybe it would... have to re-create the bitmap on update, disposing of the old one if the player's position is not the same as it was since last update.

Err.. thoughts?
Tried doing same with TextPicture that comes with MZ but converting it over for MV and then I realized that's not going to work. It'll create a bitmap using Window_Base as a temporary measure, but then what... it's designed for a fixed image is it not? Or maybe it would... have to re-create the bitmap on update, disposing of the old one if the player's position is not the same as it was since last update.
Just checked that plugin and yes, looks like it draws via Window_Base to take advantage of the drawTextEx method I mentioned, so it can use text codes like \v[x]. Then it cut+pastes that bitmap into a Sprite_Picture. The cut+paste part is only necessary because the plugin needs the game engine to recognise the text as a picture, not a window. 😴

Bitmap.prototype.drawText "blits"/"paints" the text onto the bitmap canvas, so yes, updating the text involves clearing the bitmap and redrawing. This applies regardless of whether you're using something derived from Window_Base or from Sprite, since both use Bitmap for the graphical stuff.

Suggestions:
  • Check the text each frame: only redraw it if it has changed. (May be awkward if using text codes since the expected output could change without a change in the input...)

  • Change the x and/or y coordinates of the container (i.e. the window or sprite in which you've drawn the text) each frame to match the intended position. 🙂
Well I made progress (but only after copying a several functions from MZ over to MV (window_base stuff)), but even then the font size isn't working right. It's still too big, it doesn't want to resize down >_> - grr should've taken a screenshot, already deleted everything (am trying something different)

Original thread: https://forums.rpgmakerweb.com/threads/and-rmmz-quick-help-window-sprite-floating-text.128623/