设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1749|回复: 2
打印 上一主题 下一主题

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

[复制链接]

Lv4.逐梦者

梦石
0
星屑
5692
在线时间
1556 小时
注册时间
2011-6-14
帖子
520
跳转到指定楼层
1
发表于 2022-10-5 01:33:55 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
500星屑
新建工程 没有其他插件
为什么使用 this.drawIcon 绘制图标失败


JAVASCRIPT 代码复制
  1. (function () {
  2.  
  3.     //继承菜单属性
  4.     var siakoMobi_create = Scene_Menu.prototype.create;
  5.  
  6.     Scene_Menu.prototype.create = function () {
  7.         siakoMobi_create.call(this);
  8.         //把自己写的窗口类型做成构架函数并且继承给_cuostomWindow
  9.         this._cuostomWindow = new Window_Custom();
  10.         this._cuostomWindow.y = 340;
  11.         //把窗口显示在菜单里面
  12.         this.addChild(this._cuostomWindow);
  13.     };
  14.  
  15.  
  16.     //新建窗口
  17.     function Window_Custom() {
  18.         this.initialize.apply(this, arguments);
  19.     }
  20.  
  21.     Window_Custom.prototype = Object.create(Window_Base.prototype);
  22.     Window_Custom.prototype.constructor = Window_Custom;
  23.  
  24.     Window_Custom.prototype.initialize = function (x, y) {
  25.         var width = this.windowWidth();
  26.         var height = this.windowHeight();
  27.         Window_Base.prototype.initialize.call(this, x, y, width, height);
  28.         this.refresh();
  29.     };
  30.  
  31.  
  32.     //窗口宽度
  33.     Window_Custom.prototype.windowWidth = function () {
  34.         return 240;
  35.     };
  36.  
  37.     //窗口高度
  38.     Window_Custom.prototype.windowHeight = function () {
  39.         return 200;
  40.     };
  41.  
  42.        //更新动态
  43.     Window_Custom.prototype.refresh = function () {
  44.         var x = this.textPadding();
  45.         var width = this.contents.width - this.textPadding() * 2;
  46.         this.contents.clear();
  47.         //显示文字
  48.         this.drawTextEx('这是窗口2', 0, 0);
  49.         //显示图标
  50.         this.drawIcon(64, 0, 30);
  51.    };
  52.  
  53. //窗口底层呼叫?
  54.     Window_Custom.prototype.open = function () {
  55.         this.refresh();
  56.         Window_Base.prototype.open.call(this);
  57.     };
  58.  
  59. })();

最佳答案

查看完整内容

# 如果图标图片没问题,那么可能 this.drawIcon 的原对象被修改了. 可以试试添加以下代码. 方法1: 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.contents.blt(bitmap, sx, ...

Lv4.逐梦者

梦石
0
星屑
5616
在线时间
176 小时
注册时间
2011-6-3
帖子
32
2
发表于 2022-10-5 01:33:56 | 只看该作者
本帖最后由 lqi991 于 2022-10-5 15:10 编辑

# 如果图标图片没问题,那么可能  this.drawIcon 的原对象被修改了.
    可以试试添加以下代码.
方法1:
JAVASCRIPT 代码复制
  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:
JAVASCRIPT 代码复制
  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基础编写插件,持续更新,请多多支持.
# 需求人多的优先编写!最新消息请关注下面通道.

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

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
4256
在线时间
541 小时
注册时间
2018-11-12
帖子
113
3
发表于 2022-10-5 05:49:56 | 只看该作者
试了下初始工程,显示图标没有问题。
请你检查下MV引擎的安装目录,里面的  ICON 图片是否存在问题。
回复

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-24 21:38

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表