Project1

标题: 请教大佬们,如何特定标题菜单中光标移动和确定的音效? [打印本页]

作者: hersal    时间: 2019-12-31 14:22
标题: 请教大佬们,如何特定标题菜单中光标移动和确定的音效?
让标题菜单中的光标移动和确认时的声效和其他菜单的不同。
新人初来乍到,请大佬们多多包涵!
作者: KB.Driver    时间: 2019-12-31 14:22
RUBY 代码复制
  1. class Window_TitleCommand
  2.   Sound = ::Sound.dup
  3.  
  4.   module Sound
  5.  
  6.     # 光标移动
  7.     # ["文件名", "音量", "节奏"]
  8.     SE_Cursor = ["Cursor1", 100, 100]
  9.  
  10.     # 确定
  11.     # ["文件名", "音量", "节奏"]
  12.     SE_Ok = ["Decision1", 100, 100]
  13.  
  14.     SE_Cursor = RPG::SE.new(*SE_Cursor)
  15.     SE_Ok = RPG::SE.new(*SE_Ok)
  16.  
  17.     def self.play_cursor
  18.       SE_Cursor.play
  19.     end
  20.  
  21.     def self.play_ok
  22.       SE_Ok.play
  23.     end
  24.   end  
  25.   #--------------------------------------------------------------------------
  26.   # ● 处理光标的移动
  27.   #--------------------------------------------------------------------------
  28.   def process_cursor_move
  29.     return unless cursor_movable?
  30.     last_index = @index
  31.     cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
  32.     cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
  33.     cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
  34.     cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
  35.     cursor_pagedown   if !handle?(:pagedown) && Input.trigger?(:R)
  36.     cursor_pageup     if !handle?(:pageup)   && Input.trigger?(:L)
  37.     Sound.play_cursor if @index != last_index
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ● 按下确定键时的处理
  41.   #--------------------------------------------------------------------------
  42.   def process_ok
  43.     if current_item_enabled?
  44.       Sound.play_ok
  45.       Input.update
  46.       deactivate
  47.       call_ok_handler
  48.     else
  49.       Sound.play_buzzer
  50.     end
  51.   end
  52. end


修改 SE_Cursor 与  SE_Ok  的数组可以改变对应的音效
作者: hersal    时间: 2020-1-1 16:58
感谢回答!我还想请教下代码的第2行和第4行是什么意思?
还有为什么在第8行和第12行先给这两个对象赋值,后面再新建这两个对象呢?
作者: KB.Driver    时间: 2020-1-1 19:11
hersal 发表于 2020-1-1 16:58
感谢回答!我还想请教下代码的第2行和第4行是什么意思?
还有为什么在第8行和第12行先给这两个对象赋值,后 ...

第2、第4行在这个窗口内部建立了一个Sound模块的副本,然后对这个副本作修改
这样的目的是保证其他地方的Sound模块不受影响

第8、12行赋值数组是为了方便使用者操作
后面再建立的对象的参数是基于前面数组的
作者: hersal    时间: 2020-1-1 19:48
感谢回答,受教了!




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