Project1

标题: 如何将存档和读档的光标改成图标? [打印本页]

作者: 爆焰    时间: 2013-12-5 16:08
标题: 如何将存档和读档的光标改成图标?
就是存档界面和读档界面的光标,改成我设置的图标,比如箭头图片等,请高手帮帮忙。
作者: 你最珍贵    时间: 2013-12-5 22:42
  1. #==============================================================================
  2. # ■ Window_Picture_Command
  3. #------------------------------------------------------------------------------
  4. =begin
  5. 该脚本是用图片做命令按钮,使用起来比较简单,脚本会自动判断位置。
  6. 使用方法:
  7. 与调用一般命令窗口一样!
  8. type描绘类型
  9. type = 1 只支持键盘
  10. type = 2 支持键盘+鼠标
  11. 如:先设定一个命令按钮图片以及坐标
  12. p1 = ["图片名",图片X坐标,图片Y坐标]
  13. 范例游戏里为
  14.     #################################################
  15.     s1 = ["新游戏",100,0]
  16.     s2 = ["继续游戏",200,150]
  17.     s3 = ["离开游戏",300,200]
  18.     @command_window = Window_Picture_Command.new([s1,s2,s3],type)
  19.     #################################################
  20.     这里的type的值就是刚才所支持的
  21.     type = 1 只支持键盘
  22.     type = 2 支持键盘+鼠标   
  23.     #################################################
  24.     s1 = ["新游戏",100,0]
  25.     s2 = ["继续游戏",200,150]
  26.     s3 = ["离开游戏",300,200]
  27.     @command_window = Window_Picture_Command.new([s1,s2,s3],2)
  28.     #################################################
  29.   大概就这样了,不明白看范例游戏吧。

  30. =end
  31. #==============================================================================
  32. class Window_Picture_Command < Window_Selectable
  33.   #--------------------------------------------------------------------------
  34.   # ● 初始化对像
  35.   #     width    : 窗口的宽
  36.   #     commands : 命令字符串序列
  37.   #--------------------------------------------------------------------------
  38.   def initialize(commands,type=1)
  39.     # 由命令的个数计算出窗口的高
  40.     super(0, 0, 640, 480)
  41.     @item_max = commands.size
  42.     @commands = commands
  43.     [url=home.php?mod=space&uid=81012]@Dash[/url] = []
  44.     [url=home.php?mod=space&uid=114926]@sprite[/url] = []
  45.     @type = type
  46.     @move_index = self.index
  47.     self.opacity = 0
  48.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  49.     refresh
  50.     self.index = 0
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # ● 刷新
  54.   #--------------------------------------------------------------------------
  55.   def refresh
  56.     self.contents.clear
  57.     for i in 0...@item_max
  58.       draw_picture_item(i, @type)
  59.     end
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● 释放
  63.   #--------------------------------------------------------------------------
  64.   def dispose
  65.     super
  66.     for index in @dash
  67.      if @sprite[index] != nil
  68.        @sprite[index].dispose
  69.        @sprite[index].bitmap.dispose
  70.      end
  71.     end
  72.   end  
  73.   #--------------------------------------------------------------------------
  74.   # ● 描绘图片项目
  75.   #     index : 项目编号
  76.   #     type  : 描绘类型
  77.   #     type = 1 只支持键盘
  78.   #     type = 2 双面支持
  79.   #--------------------------------------------------------------------------
  80.   def draw_picture_item(index, type)
  81.     @sprite[index] = Sprite.new
  82.     if @commands[index][0] == nil
  83.       p "图片名设置有误"
  84.     end
  85.     if @commands[index][1] == nil
  86.       p "图片X坐标设置有误"
  87.     end
  88.     if @commands[index][2] == nil
  89.       p "图片Y坐标设置有误"
  90.     end
  91.     bitmap = Bitmap.new("Graphics/Command/"+@commands[index][0])
  92.     #bitmap = RPG::Cache.picture(@commands[index][0])
  93.     @sprite[index].bitmap = bitmap
  94.     @sprite[index].x = @commands[index][1]
  95.     @sprite[index].y = @commands[index][2]
  96.     @sprite[index].index = index
  97.     if @sprite[index].index != self.index
  98.       @sprite[index].color = Color.new(0,0,0,100)
  99.     else
  100.       @sprite[index].color = Color.new(0,0,0,0)
  101.     end
  102.     @dash.push(index)
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 刷新图片项目
  106.   #--------------------------------------------------------------------------
  107.   def update_item
  108.     #if Mouse.get_mouse_pos != nil && Mouse.get_mouse_pos != 0
  109.     #$mouse_x,$mouse_y = Mouse.get_mouse_pos
  110.     #end
  111.     if @type == 2
  112.     for index in @dash
  113.      if @sprite[index] != nil
  114.       top_x = @sprite[index].x
  115.       top_y = @sprite[index].y
  116.       bottom_x = top_x + @sprite[index].bitmap.width
  117.       bottom_y = top_y + @sprite[index].bitmap.height
  118.       if ($mouse_x > top_x) and ($mouse_y > top_y) and
  119.            ($mouse_x < bottom_x) and ($mouse_y < bottom_y)
  120.            self.index = @sprite[index].index
  121.            if @move_index != self.index
  122.            Se.ok
  123.            @move_index = self.index
  124.          end
  125.       end
  126.       if @sprite[index].index != self.index
  127.         @sprite[index].color = Color.new(0,0,0,100)
  128.       else
  129.         @sprite[index].color = Color.new(0,0,0,0)
  130.       end
  131.     end
  132.     end
  133.     elsif @type == 1
  134.      for index in @dash
  135.         if @sprite[index].index != self.index
  136.          @sprite[index].color = Color.new(0,0,0,100)
  137.        else
  138.         @sprite[index].color = Color.new(0,0,0,0)
  139.        end
  140.      end  
  141.     end
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ● 图片项目无效化
  145.   #     index : 项目编号
  146.   #--------------------------------------------------------------------------
  147.   def disable_item(index)
  148.     @sprite[index].color = Color.new(0,0,0,100)
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # ● 刷新
  152.   #--------------------------------------------------------------------------
  153.   alias window_picture_command_update update
  154.   def update
  155.     window_picture_command_update
  156.     update_item
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 更新光标举行
  160.   #--------------------------------------------------------------------------
  161.   def update_cursor_rect
  162.     if [url=home.php?mod=space&uid=370741]@Index[/url] < 0
  163.       self.cursor_rect.empty
  164.       return
  165.     end
  166.     row = @index / @column_max
  167.     if row < self.top_row
  168.       self.top_row = row
  169.     end
  170.     if row > self.top_row + (self.page_row_max - 1)
  171.       self.top_row = row - (self.page_row_max - 1)
  172.     end
  173.     cursor_width = self.width / @column_max - 32
  174.     x = @index % @column_max * (cursor_width + 32)
  175.     y = @index / @column_max * 32 - self.oy
  176.     self.cursor_rect.set(x+5000, y, cursor_width, 32)
  177.   end
  178. end
  179. #==============================================================================
  180. # ■ Se
  181. #------------------------------------------------------------------------------
  182. # ■ 音效模块
  183. #==============================================================================
  184. module Se
  185.   def self.ok
  186.     $game_system.se_play($data_system.cursor_se)
  187.   end
  188.   def self.no
  189.     $game_system.se_play($data_system.cancel_se)
  190.   end
  191. end
  192. #==============================================================================
  193. # ■ Sprite
  194. #------------------------------------------------------------------------------
  195. # ■ index 选择光标
  196. #==============================================================================
  197. class Sprite
  198.   attr_accessor :index
  199. end
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1