查看: 2492|回复: 2

[有事请教] 绘制图标失败

[复制链接]
梦石
0
星屑
6963
在线时间
1557 小时
注册时间
2011-6-14
回帖
425
发表于 2022-10-5 01:33:55 | 显示全部楼层 |阅读模式
悬赏500星屑已解决
新建工程 没有其他插件
为什么使用 this.drawIcon 绘制图标失败
QQ图片20221005013257.png


  1. (function () {

  2.     //继承菜单属性
  3.     var siakoMobi_create = Scene_Menu.prototype.create;

  4.     Scene_Menu.prototype.create = function () {
  5.         siakoMobi_create.call(this);
  6.         //把自己写的窗口类型做成构架函数并且继承给_cuostomWindow
  7.         this._cuostomWindow = new Window_Custom();
  8.         this._cuostomWindow.y = 340;
  9.         //把窗口显示在菜单里面
  10.         this.addChild(this._cuostomWindow);
  11.     };


  12.     //新建窗口
  13.     function Window_Custom() {
  14.         this.initialize.apply(this, arguments);
  15.     }

  16.     Window_Custom.prototype = Object.create(Window_Base.prototype);
  17.     Window_Custom.prototype.constructor = Window_Custom;

  18.     Window_Custom.prototype.initialize = function (x, y) {
  19.         var width = this.windowWidth();
  20.         var height = this.windowHeight();
  21.         Window_Base.prototype.initialize.call(this, x, y, width, height);
  22.         this.refresh();
  23.     };


  24.     //窗口宽度
  25.     Window_Custom.prototype.windowWidth = function () {
  26.         return 240;
  27.     };

  28.     //窗口高度
  29.     Window_Custom.prototype.windowHeight = function () {
  30.         return 200;
  31.     };

  32.        //更新动态
  33.     Window_Custom.prototype.refresh = function () {
  34.         var x = this.textPadding();
  35.         var width = this.contents.width - this.textPadding() * 2;
  36.         this.contents.clear();
  37.         //显示文字
  38.         this.drawTextEx('这是窗口2', 0, 0);
  39.         //显示图标
  40.         this.drawIcon(64, 0, 30);
  41.    };

  42. //窗口底层呼叫?
  43.     Window_Custom.prototype.open = function () {
  44.         this.refresh();
  45.         Window_Base.prototype.open.call(this);
  46.     };

  47. })();
复制代码

最佳答案

查看完整内容

# 如果图标图片没问题,那么可能 this.drawIcon 的原对象被修改了. 可以试试添加以下代码. 方法1: [pre lang="javascript"]Window_Custom.prototype.drawIcon = function(iconIndex, x, y) { var bitmap = ImageManager.loadSystem('IconSet'); var pw = Window_Base._iconWidth; var ph = Window_Base._iconHeight; var sx = iconIndex % 16 * pw; var sy = Math.floor(iconIndex / 16) * ph; this.c ...
梦石
0
星屑
5626
在线时间
177 小时
注册时间
2011-6-3
回帖
29
发表于 2022-10-5 01:33:56 | 显示全部楼层
本帖最后由 lqi991 于 2022-10-5 15:10 编辑

# 如果图标图片没问题,那么可能  this.drawIcon 的原对象被修改了.
    可以试试添加以下代码.
方法1:
  1. Window_Custom.prototype.drawIcon = function(iconIndex, x, y) {
  2.     var bitmap = ImageManager.loadSystem('IconSet');
  3.     var pw = Window_Base._iconWidth;
  4.     var ph = Window_Base._iconHeight;
  5.     var sx = iconIndex % 16 * pw;
  6.     var sy = Math.floor(iconIndex / 16) * ph;
  7.     this.contents.blt(bitmap, sx, sy, pw, ph, x, y);
  8. };
复制代码

方法2:
  1. Window_Custom.prototype.drawIcon = function(iconIndex, x, y) {
  2.     var bitmap = ImageManager.loadSystem('IconSet');
  3.     var pw = Window_Base._iconWidth;
  4.     var ph = Window_Base._iconHeight;
  5.     var sx = iconIndex % 16 * pw;
  6.     var sy = Math.floor(iconIndex / 16) * ph;
  7.     bitmap.addLoadListener(function(){ this.contents.blt(bitmap, sx, sy, pw, ph, x, y);}.bind(this));
  8. };
复制代码
# 基于RMMV/MZ基础编写插件,持续更新,请多多支持.
# 需求人多的优先编写!最新消息请关注下面通道.

[插件交流群][个人插件网]
回复

使用道具 举报

梦石
0
星屑
4669
在线时间
570 小时
注册时间
2018-11-12
回帖
120
发表于 2022-10-5 05:49:56 | 显示全部楼层
试了下初始工程,显示图标没有问题。
请你检查下MV引擎的安装目录,里面的  ICON 图片是否存在问题。
1.png 2.png
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部