查看: 2183|回复: 2

[已经解决] 圖片選項腳本的問題

[复制链接]
梦石
0
星屑
354
在线时间
127 小时
注册时间
2016-10-8
回帖
54
发表于 2017-7-29 16:40:20 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 elemmy72 于 2017-7-29 16:44 编辑

圖片選項腳本
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ 图片选项(修改Window_Selectable 和 Window_Command)by 只有金刚心
  4. #  (不支持鼠标)
  5. #------------------------------------------------------------------------------
  6. # 使用方法:按照VA默认的在窗口添加指令的原方法add_command,多填写上参数就可以了。
  7. # 新增参数:
  8. # usepic - 是否使用图片,如果使用图片,则填写true,反正false
  9. # usepic的参数默认false,即不存在图片时使用VA默认的文字指令
  10. # pic- 默认显示图片,默认nil
  11. # over_pic - 当正在选择时的图片,即光标移动上去的图片,默认nil
  12. # overd - 是否已经选择,无需填写
  13. # 例如:add_command("新游戏", :new_game, true, nil, true, "图片1.png", "图片2.png")
  14. #==============================================================================

  15. class Window_Selectable < Window_Base
  16.   #--------------------------------------------------------------------------
  17.   # ● 处理光标的移动
  18.   #--------------------------------------------------------------------------
  19.   def process_cursor_move
  20.     return unless cursor_movable?
  21.     last_index = @index
  22.     cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
  23.     cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
  24.     cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
  25.     cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
  26.     cursor_pagedown   if !handle?(:pagedown) && Input.trigger?(:R)
  27.     cursor_pageup     if !handle?(:pageup)   && Input.trigger?(:L)
  28.    
  29.     #★★当光标移动时重新绘制指令★★
  30.     if @index != last_index
  31.     Sound.play_cursor
  32.     #重置指令的参数overd为false
  33.     move_overd_pic?(last_index)
  34.     contents.clear
  35.     draw_all_items
  36.     end
  37.   
  38.   end
  39.   
  40.   #--------------------------------------------------------------------------
  41.   # ● 更新光标
  42.   #--------------------------------------------------------------------------
  43.   def update_cursor
  44.     if @cursor_all
  45.       cursor_rect.set(0, 0, contents.width, row_max * item_height)
  46.       self.top_row = 0
  47.     elsif @index < 0
  48.       cursor_rect.empty
  49.     else

  50.       #★★更新图片指令★★
  51.       if pic_or_text(@index) == true
  52.         cursor_rect.empty
  53.         overd_pic?(@index)
  54.         redraw_item(@index)
  55.       #保留原来的光标
  56.       else
  57.       ensure_cursor_visible
  58.       cursor_rect.set(item_rect(@index))
  59.       end
  60.    
  61.     end
  62.   end
  63.   
  64.   #★★图片指令函数★★  
  65.   def pic_or_text(index)
  66.   end
  67.   def overd_pic(index)
  68.   end
  69.   
  70. end  

  71. class Window_Command < Window_Selectable
  72.   
  73.   #★★添加指令★★
  74.   #(保留原指令:name-指令名称,symbol-对应的符号,enabled-有效状态的标志,ext-任意的扩展数据)
  75.   #(新增参数usepic-是否使用图片,pic-默认显示图片,over_pic-当正在选择时的图片,overd-是否已经选择)
  76.   def add_command(name, symbol, enabled = true, ext = nil, usepic = false, pic = nil, over_pic = nil,overd = false)
  77.     @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext,:usepic=>usepic, :pic=>pic, :over_pic=>over_pic, :overd=>overd})
  78.   end
  79.   
  80.   #★★绘制图片指令★★
  81.   def draw_item(index)
  82.     #绘制图片指令
  83.     if @list[index][:usepic] == true && @list[index][:pic] != nil
  84.       if @list[index][:over_pic] != nil  && @list[index][:overd] == true
  85.         @bitmap = Cache.picture(@list[index][:over_pic])
  86.       else
  87.         @bitmap = Cache.picture(@list[index][:pic])
  88.       end
  89.     rect = Rect.new(0, 0, @bitmap.width, @bitmap.height)
  90.     #图片指令的坐标参照文字指令
  91.     contents.blt(index % col_max * (item_width + spacing), index / col_max * item_height, @bitmap, rect)
  92.     @bitmap.dispose
  93.     #保留原来的文字指令
  94.     else
  95.     change_color(normal_color, command_enabled?(index))
  96.     draw_text(item_rect_for_text(index), command_name(index), alignment)
  97.     end  
  98.   end
  99.   
  100.   #★★判断使用图片还是文字★★
  101.   def current_usepic?
  102.     current_data ? current_data[:usepic] : false
  103.   end
  104.   
  105.   def pic_or_text(index)
  106.     return current_usepic?
  107.   end
  108.   
  109.   #★★判断光标是否移动到图片上★★
  110.   def move_overd_pic?(index)
  111.     @list[index][:overd] = false
  112.   end
  113. end
复制代码


腳本提供插入在Window_Command裡替換掉的字串:
  def add_command(name, symbol, enabled = true, ext = nil, usepic = false, pic = nil, over_pic = nil,overd = false)
    @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext,:usepic=>usepic, :pic=>pic, :over_pic=>over_pic, :overd=>overd})
  end

這是原本不兼容鼠標版的,我連另一個兼容鼠標版的都測試過,
皆是使用給的範例測試,均有同一個問題,
就是進入戰鬥後第34行:move_overd_pic?(last_index) 會報錯!
搜尋了下似乎無人有這問題…可我是用範例測試的就出錯了呀?
(´_ゝ`)...仍未命名的遊戲製作進度:0%
梦石
0
星屑
6375
在线时间
1473 小时
注册时间
2015-7-25
回帖
609

极短25参与开拓者

发表于 2017-7-29 20:41:30 | 显示全部楼层
因为Window_Selectable里没有定义move_overd_pic?这个方法所以你需要定义一遍
  1. class Window_Selectable < Window_Base
  2.   def move_overd_pic?(index)
  3.   end
  4. end
复制代码

点评

成功了~~~非常感謝幫忙!ヽ(●´∀`●)ノ  发表于 2017-7-30 13:02

评分

参与人数 1星屑 +250 收起 理由
RaidenInfinity + 250 认可答案

查看全部评分

笨肉包的游戏讨论群932812135 (实时更新) 喜欢的话欢迎加入~
目前的坑
??? #像素风OC游戏 准备中 短篇-约5小时
花城梦之心 #像素风OC游戏 系统开发+素材绘制中
【不可思议的迷宫】幽灵契约外传:歌莉娅 v0.4 游戏文件已更新
同时更新中~ (沉迷摸鱼中~更新速度较慢请见谅w)
这是属于笨肉包一个人的旅行~(这只肉包又在摸鱼!
旅途的最终目标~ ???(保密~
回复 1 0

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部