赞 | 0 |
VIP | 10 |
好人卡 | 49 |
积分 | 10 |
经验 | 22958 |
最后登录 | 2020-8-1 |
在线时间 | 2161 小时 |
Lv3.寻梦者 酱油的
- 梦石
- 0
- 星屑
- 1030
- 在线时间
- 2161 小时
- 注册时间
- 2007-12-22
- 帖子
- 3271
|
可以給個模板你:
- #==============================================================================
- # ■ Window_Item
- #------------------------------------------------------------------------------
- # 物品画面、战斗画面、显示浏览物品的窗口。
- #==============================================================================
- class Window_Item_Build < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 64, 640, 416)
- @column_max = 2
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- # 添加报务
- for i in 1...$data_items.size
- if $game_party.item_number(i) > 0
- @data.push($data_items[i])
- end
- end
- for i in 1...$data_weapons.size
- if $game_party.weapon_number(i) > 0
- @data.push($data_weapons[i])
- end
- end
- for i in 1...$data_armors.size
- if $game_party.armor_number(i) > 0
- @data.push($data_armors[i])
- end
- end
- # 如果项目数不是 0 就生成位图、重新描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- @data.each {|i| draw_item(i)}
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
- if item.is_a?(RPG::Item) and
- $game_party.item_can_use?(item.id)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- x = 4 + index % 2 * (288 + 32)
- y = index / 2 * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
- self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.item == nil ? "" : self.item.description)
- end
- end
- #==============================================================================
- # ■ Scene_Base
- #------------------------------------------------------------------------------
- # 模仿 VX 寫的游戲界面超級類(偷懶用)
- #==============================================================================
- class Scene_Base
- #--------------------------------------------------------------------------
- # ● 主處理
- #--------------------------------------------------------------------------
- def main
- window_create #生成窗口
- Graphics.transition #執行過渡
- loop_do #主循環
- Graphics.freeze #準備過渡
- window_dispose #釋放窗口
- background_dispose #背景釋放
- end
- #--------------------------------------------------------------------------
- # ● 主循環
- #--------------------------------------------------------------------------
- def loop_do
- loop do
- Graphics.update #刷新「游戏畫面」
- Input.update #刷新「輸入信息」
- update #刷新畫面
- background_update #背景刷新
-
- #如果切換畫面就中斷循環
- break if $scene != self
- end
- end
- #--------------------------------------------------------------------------
- # ● 生成主要窗口
- #--------------------------------------------------------------------------
- def window_create
- end
- #--------------------------------------------------------------------------
- # ● 刷新畫面
- #--------------------------------------------------------------------------
- def update
- end
- #--------------------------------------------------------------------------
- # ● 釋放窗口
- #--------------------------------------------------------------------------
- def window_dispose
- end
- #--------------------------------------------------------------------------
- # ● 背景刷新
- #--------------------------------------------------------------------------
- def background_update
- @background.update unless @background.nil?
- end
- #--------------------------------------------------------------------------
- # ● 背景釋放
- #--------------------------------------------------------------------------
- def background_dispose
- @background.dispose unless @background.nil?
- end
- end
- #==============================================================================
- # ■ Scene_Base
- #------------------------------------------------------------------------------
- # 游戲界面的子類版(偷懶用)
- #==============================================================================
- class SupScene < Scene_Base
- #--------------------------------------------------------------------------
- # ● 主處理
- #--------------------------------------------------------------------------
- def main
- super
- end
- #--------------------------------------------------------------------------
- # ● 生成主要窗口
- #--------------------------------------------------------------------------
- def window_create
- @window_item = Window_Item_Build.new
- end
- #--------------------------------------------------------------------------
- # ● 釋放窗口
- #--------------------------------------------------------------------------
- def window_dispose
- @window_item.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新畫面
- #--------------------------------------------------------------------------
- def update
- if @window_item.active
- update_item
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新畫面(update_item)
- #--------------------------------------------------------------------------
- def update_item
- end
- end
复制代码
|
|