| 赞 | 46 |
| VIP | |
| 好人卡 | |
| 积分 | 97 |
| 经验 | |
| 最后登录 | 2026-6-17 |
| 在线时间 | 2775 小时 |
梦石0
星屑9716
在线时间2775 小时
注册时间2008-9-5
回帖3458
   
|
发表于 2015-8-20 23:09:49
|
显示全部楼层
()
默认的是直接用【Window_Command】,为了避免其他冲突,另写了一个独立战斗角色命令窗口(Main前Insert):
点击展开/收起- #==============================================================================
- # ■ Window_Command
- #------------------------------------------------------------------------------
- # 一般的命令选择行窗口。
- #==============================================================================
- class Window_Battler_Command < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # width : 窗口的宽
- # commands : 命令字符串序列
- #--------------------------------------------------------------------------
- def initialize(width, commands)
- # 由命令的个数计算出窗口的高
- super(0, 0, width, (commands.size + 1) * 32 + 32)
- @item_max = commands.size
- @commands = commands
- @actor = nil
- self.contents = Bitmap.new(width - 32, (@item_max + 1) * 32)
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh(actor = @actor)
- self.contents.clear
- @actor = actor
- self.contents.draw_text(0, 0, self.contents.width, 32, @actor.name) if @actor
- for i in 0...@item_max
- draw_item(i, normal_color)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- # color : 文字色
- #--------------------------------------------------------------------------
- def draw_item(index, color)
- self.contents.font.color = color
- rect = Rect.new(4, 32 * (index + 1), self.contents.width - 8, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- self.contents.draw_text(rect, @commands[index])
- end
- #--------------------------------------------------------------------------
- # ● 项目无效化
- # index : 项目编号
- #--------------------------------------------------------------------------
- def disable_item(index)
- draw_item(index, disabled_color)
- end
- #--------------------------------------------------------------------------
- # ● 更新光标矩形
- #--------------------------------------------------------------------------
- def update_cursor_rect
- # 光标位置不满 0 的情况下
- if @index < 0
- self.cursor_rect.empty
- return
- end
- # 获取当前的行
- row = @index / @column_max
- # 当前行被显示开头行前面的情况下
- if row < self.top_row
- # 从当前行向开头行滚动
- self.top_row = row
- end
- # 当前行被显示末尾行之后的情况下
- if row > self.top_row + (self.page_row_max - 1)
- # 从当前行向末尾滚动
- self.top_row = row - (self.page_row_max - 1)
- end
- # 计算光标的宽度
- cursor_width = self.width / @column_max - 32
- # 计算光标坐标
- x = @index % @column_max * (cursor_width + 32)
- y = (@index + 1) / @column_max * 32 - self.oy
- # 更新光标矩形
- self.cursor_rect.set(x, y, cursor_width, 32)
- end
- end
复制代码
用法是在【Scene_Battle 1】里面一开始建立命令窗口的那里,把- @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
复制代码 改成- @actor_command_window = Window_Battler_Command.new(160, [s1, s2, s3, s4])
复制代码 然后在(默认的)【Scene_Battle 3】里面的【def phase3_setup_command_window】这段里面,
在最后面加上一句- @actor_command_window.refresh(@active_battler)
复制代码 PS:如果用了别的战斗系统,试着搜索【def phase3_setup_command_window】,然后在对应位置加上。
PS2:临时写的东西,不能保证是不是会出错……(雾
|
评分
-
查看全部评分
|