[脚本]物品快捷键222.209.1.*来看
rmxp吧
全部回复
仅看楼主
level 5
小小SLM 楼主
class Window_Item_KeyCommand < Window_Selectable
   #--------------------------------------------------------------------------
   # ● 初始化对像
   #--------------------------------------------------------------------------
   def initialize
     super(217-16, 489-78, 346, 96)
     self.contents = Bitmap.new(width - 32, height - 32)
     self.opacity = 0
     @item_max = 3
     @column_max = 3
     @commands = ["Z", "X", "C"]
     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"]
         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 = 60 + 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,26, 128, 32,"x")
           self.contents.draw_text(x+10,24, 128, 40,"#{$game_party.item_number(item.id)}")
         end
           u += 1
       end
     end
     for i in 0...@item_max
       draw_item(i)
     end
   end
   #--------------------------------------------------------------------------
   # ● 描绘项目

2010年02月11日 05点02分 1
level 5
小小SLM 楼主
   #      index : 项目编号
   #--------------------------------------------------------------------------
   def draw_item(index)
     x = 70 + index * (180)/6
     self.contents.font.size = 14
     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(60+x, y+8, 30, 40)
   end
end
#==============================================================================
# ■ Scene_Key
#------------------------------------------------------------------------------
#    处理中快捷键的类。
#==============================================================================
class Scene_Item_Key < Scene_Base
   #--------------------------------------------------------------------------
   # ● 初始化对像
   #      actor_index : 角色索引
   #--------------------------------------------------------------------------
   def initialize(actor_index = 0)
     @actor_index = actor_index
     super()
   end
   #--------------------------------------------------------------------------

2010年02月11日 05点02分 2
level 5
小小SLM 楼主
   # ● 主处理
   #--------------------------------------------------------------------------
   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
       $game_switches[11] = true
       return
     end
     # 按下 C 键的场合下
     if Input.trigger?(Input::C)

2010年02月11日 05点02分 3
level 5
小小SLM 楼主
       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)
       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

2010年02月11日 05点02分 4
1