Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.
Original Source
- Original title: MZ Problem drawing different sized icons
- Original author: BurningOrca
- Original date: September 4, 2022
- Source thread: https://forums.rpgmakerweb.com/threads/problem-drawing-different-sized-icons.151067/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Javascript/Plugin Support
Summary
I just want to draw Icons in different sizes, therefore I've copied the code of Window_Base.prototype.drawIcon into the following function and added width/height parameters: JavaScript: Window_Base.prototype.drawSizedIcon = function(iconIndex, x, y, width, height) {
Archived First Post
I just want to draw Icons in different sizes, therefore I've copied the code of Window_Base.prototype.drawIcon into the following function and added width/height parameters:
But for some reason this did not look like I've expected.
To better tell you what I mean take a look at the completely simplified IconSet I've uploaded here. I've surrounded Icon 17 with a red square 34 by 34 pixel, while Icons are 32 by 32 pixel.
Icon 17 starts at 17 % 16 = 1 * 32 = 32 and Math.floor(17 / 16) = 1 * 32 = 32, but the start of the red square is at Pixel (31, 31), yet if I modify Window_BattleStatus.prototype.refresh in the following way and start battle test I can see the red square:
Protected download
Why? What did I do wrong? I don't want to see the sorroundings of the icons next to the icon I want to draw in larger size.
Additional Hint:
I've deactived all plugins except the one that contains my two modified functions I've posted here and it still looks like this.
JavaScript:
Window_Base.prototype.drawSizedIcon = function(iconIndex, x, y, width, height)
{
const bitmap = ImageManager.loadSystem("IconSet");
const sw = ImageManager.iconWidth;
const sh = ImageManager.iconHeight;
const sx = (iconIndex % 16) *sw;
const sy = Math.floor(iconIndex / 16) * sh;
this.contents.blt(bitmap, sx, sy, sw, sh, x, y, width, height);
}
But for some reason this did not look like I've expected.
To better tell you what I mean take a look at the completely simplified IconSet I've uploaded here. I've surrounded Icon 17 with a red square 34 by 34 pixel, while Icons are 32 by 32 pixel.
Icon 17 starts at 17 % 16 = 1 * 32 = 32 and Math.floor(17 / 16) = 1 * 32 = 32, but the start of the red square is at Pixel (31, 31), yet if I modify Window_BattleStatus.prototype.refresh in the following way and start battle test I can see the red square:
JavaScript:
_refreshStatusWindow = Window_BattleStatus.prototype.refresh;
Window_BattleStatus.prototype.refresh = function()
{
_refreshStatusWindow.call(this);
const item2 = this.itemRect(2);
const startX = item2.x;
const colSpacing = this.colSpacing();
const remainingWidth = this.innerWidth - colSpacing - startX;
const height = item2.height / 3;
const gaugeWidth = (remainingWidth - colSpacing) / 2;
const iconSize = Math.floor(height);
this.contents.fontSize = iconSize;
const startX2 = startX + remainingWidth / 2 + colSpacing / 2;
this.drawSizedIcon(17, startX2, item2.y, iconSize, iconSize);
this.drawText("x " + $gameParty.gold(), startX2 + iconSize + 2, item2.y + 10, gaugeWidth - height, 'left');
this.resetFontSettings();
}
Protected download
Why? What did I do wrong? I don't want to see the sorroundings of the icons next to the icon I want to draw in larger size.
Additional Hint:
I've deactived all plugins except the one that contains my two modified functions I've posted here and it still looks like this.
Downloads / Referenced Files
Log in to download
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadReferenced Images / Attachments
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
0
replies
1
view
Topic Summary
Loading summary...
