=begin 作者:轩辕合流 日期:20221/2/26 晚 小雨 鸣谢:Project1 =end class Window_ItemMessage < Window_Base def initialize # 初始化 super(0, 0, 240, 240) self.contents = Bitmap.new(self.width - 32, self.height - 32) @item = nil refresh end def refresh # 刷新 需要的内容往这里塞行 self.contents.clear self.contents.font.size = 18 draw_item_name(@item, 0, -4) self.contents.fill_rect(0, 28, self.width - 32, 1, normal_color) self.contents.font.size = 14 self.contents.font.color = text_color(6) self.contents.draw_text(0, 24, 96, 32, "上级") self.contents.font.color = text_color(4) self.contents.draw_text(0, 24, self.width - 32, 32, "稀有", 2) self.contents.font.size = 12 self.contents.font.color = text_color(5) self.contents.draw_text(32, 24, 96, 32, "(100%)") self.contents.draw_text(0, 24+16, 96, 32, "2.8kg") end def set_item(item) # 默认的脚本刷新方法,感觉比@old_index != self.index好用 if @item != item @item = item refresh end end end class Scene_Item alias :foodUpdate_item :update_item def update_item foodUpdate_item # alias 的语法 @food_item = @item_window.item # 获取物品 if @food_item != nil if @message_window != nil# 释放以前的窗口 @message_window.dispose @message_window = nil end @message_window = Window_ItemMessage.new # 生成新的窗口 # 计算坐标 @message_window.x = 64 + @item_window.index % 2 * 320 @message_window.y = @item_window.index / 2 < 4 ? 96 + @item_window.index / 2 * 32 : 96 + 4 * 32 @message_window.z = 200 @message_window.back_opacity = 185 # 传递物品 @message_window.set_item(@item_window.item) end end alias :foodDispose :dispose def dispose # 释放 foodDispose if @message_window != nil @message_window.dispose @message_window = nil end end end # by:轩辕合流
QQ截图20210226043120.png (102.28 KB, 下载次数: 24)
哈哈哈
RPGzh500223 发表于 2021-2-26 17:45
class Window_ItemMessage < Window_Base 和 index 有什么关系?
如果描绘很多行文字的话
建议设置一个每行 ...
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |