adjusting the DY cuts off the Icon if I use -10
That's because the icon is being painted to the gauge bitmap's canvas. The canvas starts at 0, but you're trying to start painting at
labelY() (default 3) - 10, so the top 7 px will be cut off.
I hadn't noticed earlier, but there's a similar issue for any Y-shift:
Sprite_Gauge has a default height of 32 px, which is exactly enough for a standard-size icon. If your icons have no blank space around them, try
DY = -3.
Would it be a heavy lift to have the icon resizable?
Bitmap#blt recognises optional destination width/height arguments, e.g. draw at 16x16 px:
JavaScript:
bitmap.blt(b, sx, sy, pw, ph, x, y, 16, 16);
However, scaling pixel art rarely gives good results, so:
- If you want the icon smaller, I'd suggest just making it smaller in its 32x32 px box on the icon sheet.
- If you want it larger, it'd probably be best to use an entirely different approach. E.g. add the gauge icon as a new child sprite of the gauge. Maybe like this:
Spoiler: plugin code v2
JavaScript:
/*:
* @target MZ
* @plugindesc Images for gauge labels.
* @author Caethyril
* @url https://forums.rpgmakerweb.com/threads/167682/
* @help Images should be placed in the img/system subfolder.
* Edit the plugin code to customise image filenames.
*
* Free to use and/or modify for any project, no credit required.
*/
;void (() => {
'use strict';
/**
* Maps gauge type to `img/system` filename, for label.
* Unlisted types are unaffected.
*/
const DATA = {
hp: "gaugeLabel_hp",
mp: "gaugeLabel_mp",
tp: "gaugeLabel_tp"
};
/** X position (parent coords) for gauge label image. */
const X = 0;
/** Y position (parent coords) for gauge label image. */
const Y = 0;
/** Identifier for new "image label child sprite" property on `Sprite_Gauge`. */
const P = "_imageLabelSprite";
/**
* Ensures child sprite for gauge label image is present when appropriate.
* @this Sprite_Gauge
* @returns {boolean} `true` iff image label sprite is now present.
*/
const ensureGaugeImageLabel = function() {
const t = this._statusType;
const s = DATA[t];
if (s) {
if (!this[P]) {
const c = this[P] = new Sprite(ImageManager.loadSystem(s));
c.move(X, Y);
this.addChild(c);
}
return true;
}
return false;
};
// Patch - use image for gauge label instead, when appropriate.
const alias = Sprite_Gauge.prototype.drawLabel;
Sprite_Gauge.prototype.drawLabel = function() {
if (!ensureGaugeImageLabel.call(this))
alias.apply(this, arguments);
};
})();