赞 | 0 |
VIP | 7 |
好人卡 | 0 |
积分 | 1 |
经验 | 6490 |
最后登录 | 2023-11-21 |
在线时间 | 204 小时 |
Lv1.梦旅人 殲滅天使·玲
- 梦石
- 0
- 星屑
- 121
- 在线时间
- 204 小时
- 注册时间
- 2008-2-20
- 帖子
- 2292
|
2星屑
- #==============================================================================
- # ■ Window_Item_KeyCommand
- #------------------------------------------------------------------------------
- # 选择快捷键的窗口
- #==============================================================================
- class Window_Item_KeyCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(160-16, 480-78, 346, 96)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.opacity = 0
- @item_max = 7
- @column_max = 7
- @commands = ["Z", "X", "C","V","B","N","M"]
- refresh
- self.index = -1
- self.active = false
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh(actor=nil)
- self.contents.clear
- if actor != nil
- u = 0
- for key in ["Z", "X", "C","V","B","N","M"]
- item = $data_items[actor.item_key[key]]
- if !item.nil?
- if $game_party.item_number(item.id) == 0
- actor.item_key[key] = 0
- refresh(actor)
- return
- end
- bitmap = RPG::Cache.icon(item.icon_name)
- x = 58 + u * (320-32)/4
- self.contents.font.size = 12
- self.contents.font.color = Color.new(255,255,255,255)
- self.contents.blt(x,16,bitmap,Rect.new(0,0,30,30))
- self.contents.draw_text(x, 24, 128, 32, item.name)
- self.contents.draw_text(x+25, 12, 128, 32, "x")
- self.contents.draw_text(x+32, 12, 128, 32, "#{$game_party.item_number(item.id)}")
- end
- u += 1
- end
- end
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- x = 53 + index * (320-32)/4
- self.contents.font.size = 16
- self.contents.font.color = Color.new(20,20,20)
- self.contents.draw_text(x+1, 1, 128, 32, @commands[index])
- self.contents.font.color = Color.new(135,175,255)
- self.contents.draw_text(x, 0, 128, 32, @commands[index])
- 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 * (320-32)/4
- y = @index / @column_max * 32 - self.oy
- # 更新国标矩形
- self.cursor_rect.set(48+x, y+8, 64, 40)
- end
- end
- #==============================================================================
- # ■ Scene_Key
- #------------------------------------------------------------------------------
- # 处理中快捷键的类。
- #==============================================================================
- class Scene_Item_Key < Scene_Base
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # actor_index : 角色索引
- #--------------------------------------------------------------------------
- def initialize(actor_index = 0)
- @actor_index = actor_index
- super()
- end
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main_start
- super
- # 获取角色
- @actor = $game_party.actors[@actor_index]
- # 生成帮助窗口、状态窗口、特技窗口
- @help_window = Window_Help.new
- @item_window = Window_Item.new#(@actor)
- @item_window.z -= 98
- @item_window.height = 256
- @item_window.back_opacity = 160
- @help_window.back_opacity = 160
- @key_window = Window_Item_KeyCommand.new
- @key_window.refresh(@actor)
- # 关联帮助窗口
- @item_window.help_window = @help_window
-
-
- @windows.push(@help_window)
- @windows.push(@item_window)
- @windows.push(@key_window)
- end
- def make_sprite
- @spriteset = Spriteset_Map.new
- @arpg_actor = ARPG_Actor.new
- end
- def dispose_sprite
- @spriteset.dispose
- @arpg_actor.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新命令窗口
- @arpg_actor.update
- if @item_window.active
- update_item
- return
- end
- if @key_window.active
- update_key
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新技能窗口
- #--------------------------------------------------------------------------
- def update_item
- @item_window.update
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到菜单画面
- $scene = Scene_Map.new
- return
- end
- # 按下 C 键的场合下
- if Input.trigger?(Input::C)
- item = @item_window.item
- return if !$game_party.item_can_use?(item.id)
- M.ok
- @item_window.active = false
- @key_window.active = true
- @key_window.index = 0
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新选择键位
- #--------------------------------------------------------------------------
- def update_key
- @key_window.update
- if Input.trigger?(Input::C)
- item = @item_window.item
- case @key_window.index
- when 0
- key_start("Z",item)
- when 1
- key_start("X",item)
- when 2
- key_start("C",item)
- when 3
- key_start("V",item)
- when 4
- key_start("B",item)
- when
- key_start("N",item)
- when 6
- key_start("M",item)
- end
- end
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- @item_window.active = true
- @key_window.active = false
- @key_window.index = -1
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 设置键位
- #--------------------------------------------------------------------------
- def key_start(key,item)
- if item.nil?
- @actor.item_key[key] = 0
- else
- @actor.item_key[key] = item.id
- end
- @item_window.active = true
- @key_window.active = false
- @key_window.index = -1
- @key_window.refresh(@actor)
- M.eq
- return
- end
- end
复制代码- #==============================================================================
- # ■ Window_KeyCommand
- #------------------------------------------------------------------------------
- # 选择快捷键的窗口
- #==============================================================================
- class Window_KeyCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(73-16, 480-106, 520, 155)#(73-16, 480-71, 520, 155)
- self.contents = Bitmap.new(width - 29, height - 29)
- self.opacity = 0
- @item_max = 7
- @column_max = 7
- @commands = ["A", "S", "D", "F","G","H","J"]
- refresh
- self.index = -1
- self.active = false
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh(actor=nil)
- self.contents.clear
- if actor != nil
- u = 0
- for key in ["A", "S", "D", "F","G","H","J"]
- skill = $game_skills[actor.key[key]]
- if !skill.nil?
- bitmap = RPG::Cache.icon(skill.icon_name)
- x = 305 + u * (180)/6
- self.contents.font.size = 12
- self.contents.font.color = Color.new(255,255,255,255)
- self.contents.blt(x,16,bitmap,Rect.new(0,0,30,30))
- self.contents.draw_text(x+16, 8, 128, 32, skill.name)
- self.contents.draw_text(x, 24, 128, 32, "SP:#{skill.sp_cost}")
- end
- u += 1
- end
- end
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- x = 315 + index * (180)/6
- self.contents.font.size = 16
- self.contents.font.color = Color.new(20,20,20)
- self.contents.draw_text(x+1, 1, 128, 32, @commands[index])
- self.contents.font.color = Color.new(135,175,255)
- self.contents.draw_text(x, 0, 128, 32, @commands[index])
- 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 - 30
- # 计算光标坐标
- x = @index % @column_max * (180)/6
- y = @index / @column_max * 32 - self.oy
- # 更新国标矩形
- self.cursor_rect.set(305+x, y+8, 30, 40)
- end
- end
- #==============================================================================
- # ■ Scene_Key
- #------------------------------------------------------------------------------
- # 处理中快捷键的类。
- #==============================================================================
- class Scene_Key < Scene_Base
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # actor_index : 角色索引
- #--------------------------------------------------------------------------
- def initialize(actor_index = 0)
- @actor_index = actor_index
- super()
- end
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main_start
- super
- @actor = $game_party.actors[@actor_index]
- # 生成帮助窗口、状态窗口、特技窗口
- @help_window = Window_Help.new
- @skill_window = Window_Skill.new(@actor)
- @skill_window.z -= 98
- @skill_window.height = 256
- @skill_window.back_opacity = 160
- @help_window.back_opacity = 160
- @key_window = Window_KeyCommand.new
- @key_window.refresh(@actor)
- # 关联帮助窗口
- @skill_window.help_window = @help_window
- @windows.push(@help_window)
- @windows.push(@skill_window)
- @windows.push(@key_window)
- end
- def make_sprite
- @spriteset = Spriteset_Map.new
- @arpg_actor = ARPG_Actor.new
- end
- def dispose_sprite
- @spriteset.dispose
- @arpg_actor.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新命令窗口
- @arpg_actor.update
- if @skill_window.active
- update_skill
- return
- end
- if @key_window.active
- update_key
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新技能窗口
- #--------------------------------------------------------------------------
- def update_skill
- @skill_window.update
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到菜单画面
- $scene = Scene_Map.new
- return
- end
- # 按下 C 键的场合下
- if Input.trigger?(Input::C)
- M.ok
- @skill_window.active = false
- @key_window.active = true
- @key_window.index = 0
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新选择键位
- #--------------------------------------------------------------------------
- def update_key
- @key_window.update
- if Input.trigger?(Input::C)
- skill = @skill_window.skill
- case @key_window.index
- when 0
- key_start("A",skill)
- when 1
- key_start("S",skill)
- when 2
- key_start("D",skill)
- when 3
- key_start("F",skill)
- when 4
- key_start("G",skill)
- when 5
- key_start("H",skill)
- when 6
- key_start("J",skill)
- end
- end
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- @skill_window.active = true
- @key_window.active = false
- @key_window.index = -1
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 设置键位
- #--------------------------------------------------------------------------
- def key_start(key,skill)
- if skill.nil?
- @actor.key[key] = 0
- else
- @actor.key[key] = skill.id
- end
- @skill_window.active = true
- @key_window.active = false
- @key_window.index = -1
- @key_window.refresh(@actor)
- M.eq
- return
- end
- end
复制代码 技能栏的脚本是上面那个,物品栏是下面那个。自己折腾不出来 - -。
然后效果如下。
坐标是…X565 Y145 左边这一排第一格的左上角坐标。 X605 Y145 右边这一排第一格的左上角坐标。
然后目的是把这个技能栏和物品栏丢进格子里- -。
还有光标的描绘。就这样。恩= = |
|