查看: 2831|回复: 1

[已经解决] 【关于菜单的问题】

[复制链接]
梦石
0
星屑
155
在线时间
149 小时
注册时间
2015-10-14
回帖
187
发表于 2016-1-5 22:07:23 | 显示全部楼层 |阅读模式

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

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

×
嗯,没错 又是我

1.怎么更改菜单背景的不透明度?/怎么去掉菜单背景?
2.如果我想从某个事件直接连接到外站脚本的功用,我该填什么?

以下是脚本↓
  1. #encoding:utf-8

  2. =begin
  3. *******************************************************************************************

  4.    * Lctseng - 系統設定畫面 *

  5.                        for RGSS3

  6.         Ver 1.01   2013.09.02

  7.    原作者:魂(Lctseng),巴哈姆特論壇ID:play123
  8.    原文發表於:巴哈姆特RPG製作大師哈拉版

  9.    轉載請保留此標籤

  10.    個人小屋連結:[url]http://home.gamer.com.tw/homeindex.php?owner=play123[/url]

  11.    主要功能:
  12.                        一、設定BGM(ME)、SE(BGS)、亮度的大小
  13.                        二、具有"重置"功能

  14.    更新紀錄:
  15.     Ver 1.00 :
  16.     日期:2013.08.18
  17.     摘要:一、最初版本


  18.    更新紀錄:
  19.     Ver 1.01 :
  20.     日期:2013.09.02
  21.     摘要:一、新增重置功能,允許調整各圖示的位置

  22.    

  23.     撰寫摘要:一、此腳本修改或重新定義以下類別:
  24.                           1.Scene_Base
  25.                           2.Audio
  26.                           
  27.                           
  28.                           二、此腳本新定義以下類別和模組:
  29.                           1.Lctseng::SystemOption
  30.                           2.Game_SystemOption
  31.                           3.Scene_SystemOption
  32.                           4.Spriteset_OptionBar
  33.                           5.Sprite_OptionArrow
  34.                           

  35. *******************************************************************************************

  36. =end

  37. #*******************************************************************************************
  38. #
  39. #   請勿修改從這裡以下的程式碼,除非你知道你在做什麼!
  40. #   DO NOT MODIFY UNLESS YOU KNOW WHAT TO DO !
  41. #
  42. #*******************************************************************************************

  43. #--------------------------------------------------------------------------
  44. # ★ 紀錄腳本資訊
  45. #--------------------------------------------------------------------------
  46. if !$lctseng_scripts  
  47.   $lctseng_scripts = {}
  48. end
  49. $lctseng_scripts[:system_option] = "1.01"

  50. puts "載入腳本:Lctseng - 系統設定畫面,版本:#{$lctseng_scripts[:system_option]}"
  51.   
  52. #encoding:utf-8
  53. #==============================================================================
  54. # ■ Lctseng::SystemOption
  55. #------------------------------------------------------------------------------
  56. #  有關系統設定選單的設定
  57. #==============================================================================
  58. module Lctseng
  59. module SystemOption
  60.   #--------------------------------------------------------------------------
  61.   # ● 顯示條的寬高,配合圖片填寫
  62.   #--------------------------------------------------------------------------
  63.   Bar_Width = 290
  64.   Bar_Height = 43
  65.   #--------------------------------------------------------------------------
  66.   # ● 顯示條的X座標(全部統一)
  67.   #--------------------------------------------------------------------------
  68.   Bar_X = 236
  69.   #--------------------------------------------------------------------------
  70.   # ● 顯示條的Y座標(三個分開)
  71.   #--------------------------------------------------------------------------
  72.   Bar_Y = [101,193,296]
  73.   #--------------------------------------------------------------------------
  74.   # ● 箭頭的X座標(全部統一)
  75.   #--------------------------------------------------------------------------
  76.   ARROW_X = 47
  77.   #--------------------------------------------------------------------------
  78.   # ● 箭頭的Y座標(四個分開)
  79.   #--------------------------------------------------------------------------
  80.   ARROW_Y = [99,205,308,384]
  81.   
  82. end
  83. end



  84. #encoding:utf-8
  85. #==============================================================================
  86. # ■ Audio
  87. #------------------------------------------------------------------------------
  88. #  內建的聲音模組
  89. #==============================================================================
  90. module Audio
  91.   #--------------------------------------------------------------------------
  92.   # ★ 方法重新定義
  93.   #--------------------------------------------------------------------------
  94.   class << self
  95.   unless @lctseng_for_system_option_on_Audio_alias
  96.     alias lctseng_for_system_option_on_Audio_for_Bgm_play bgm_play # 播放背景音樂
  97.     alias lctseng_for_system_option_on_Audio_for_me_play me_play # 播放音樂
  98.     alias lctseng_for_system_option_on_Audio_for_Bgs_play bgs_play # 播放背景音效
  99.     alias lctseng_for_system_option_on_Audio_for_se_play se_play # 播放音效
  100.     @lctseng_for_system_option_on_Audio_alias = true
  101.   end
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ● 設定聲音的大小比率(百分比)
  105.   #--------------------------------------------------------------------------
  106.   def self.set_sound_rate(rate)
  107.     @sound_rate = rate / 100.0
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # ● 設定音樂的大小比率(百分比)
  111.   #--------------------------------------------------------------------------
  112.   def self.set_music_rate(rate)
  113.     @music_rate = rate / 100.0
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● 設定聲音的大小比率(百分比),含效果
  117.   #--------------------------------------------------------------------------
  118.   def self.set_sound_rate_with_effect(rate)
  119.     old_rate = @sound_rate
  120.     old_music = RPG::BGS.last.clone
  121.     #puts "原比率:#{old_rate}"
  122.     old_music.volume =  (old_music.volume / old_rate).round
  123.     #puts "原音量:#{old_music.volume}"
  124.     RPG::BGS.stop
  125.     set_sound_rate(rate)
  126.     old_music.volume *= @sound_rate
  127.     old_music.volume = 100 if old_music.volume > 100
  128.     puts "位置:#{old_music.pos}"
  129.     old_music.replay
  130.     ##
  131.     name = 'SoundOptionEffect'
  132.     se_play('Audio/SE/' + name)
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ● 設定音樂的大小比率(百分比),含效果
  136.   #--------------------------------------------------------------------------
  137.   def self.set_music_rate_with_effect(rate)
  138.     old_rate = @music_rate
  139.     old_music = RPG::BGM.last.clone
  140.     #puts "原比率:#{old_rate}"
  141.     old_music.volume =  (old_music.volume / old_rate).round
  142.     #puts "原音量:#{old_music.volume}"
  143.     RPG::BGM.stop
  144.     set_music_rate(rate)
  145.     old_music.volume *= @music_rate
  146.     old_music.volume = 100 if old_music.volume > 100
  147.     puts "位置:#{old_music.pos}"
  148.     old_music.pos += 60000
  149.     old_music.replay
  150.   end  
  151.   #--------------------------------------------------------------------------
  152.   # ● 播放背景音樂
  153.   #--------------------------------------------------------------------------
  154.   def self.bgm_play(filename,volume = 100,pitch = 100,pos = 0)
  155.     if !@music_rate
  156.       @music_rate = 1.0
  157.     end
  158.     volume = (volume * @music_rate).round
  159.     lctseng_for_system_option_on_Audio_for_Bgm_play(filename,volume,pitch,pos)
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # ● 播放音樂
  163.   #--------------------------------------------------------------------------
  164.   def self.me_play(filename,volume = 100,pitch = 100)
  165.     if !@music_rate
  166.       @music_rate = 1.0
  167.     end
  168.     volume = (volume * @music_rate).round
  169.     lctseng_for_system_option_on_Audio_for_me_play(filename,volume,pitch)
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● 播放背景音效
  173.   #--------------------------------------------------------------------------
  174.   def self.bgs_play(filename,volume = 80,pitch = 100,pos = 0)
  175.     if !@sound_rate
  176.       @sound_rate = 1.0
  177.     end
  178.     volume = (volume * @sound_rate).round
  179.     lctseng_for_system_option_on_Audio_for_Bgs_play(filename,volume,pitch,pos)
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ● 播放音效
  183.   #--------------------------------------------------------------------------
  184.   def self.se_play(filename,volume = 80,pitch = 100)
  185.     if !@sound_rate
  186.       @sound_rate = 1.0
  187.     end
  188.     volume = (volume * @sound_rate).round
  189.     lctseng_for_system_option_on_Audio_for_se_play(filename,volume,pitch)
  190.   end  
  191. end


  192. #encoding:utf-8
  193. #==============================================================================
  194. # ■Game_SystemOption
  195. #------------------------------------------------------------------------------
  196. #  管理系統資訊的視窗
  197. #==============================================================================
  198. class Game_SystemOption
  199.   #--------------------------------------------------------------------------
  200.   # ● 定義實例變數
  201.   #--------------------------------------------------------------------------
  202.   attr_accessor :volume_music
  203.   attr_accessor :volume_sound
  204.   attr_accessor :brightness
  205.   #--------------------------------------------------------------------------
  206.   # ● 初始化對象
  207.   #--------------------------------------------------------------------------
  208.   def initialize
  209.     clear_all_data
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● 重置
  213.   #--------------------------------------------------------------------------
  214.   def reset
  215.     puts "執行重置"
  216.     clear_all_data
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ● 取得三大資料的陣列型態
  220.   #--------------------------------------------------------------------------
  221.   def data_array
  222.     [@volume_music,@volume_sound,@brightness]
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● 取得三大資料的比率資訊
  226.   #--------------------------------------------------------------------------
  227.   def data_rates
  228.     [@volume_music/100.0,@volume_sound/100.0,@brightness/455.0]
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # ● 清除所有資料
  232.   #--------------------------------------------------------------------------
  233.   def clear_all_data
  234.     @volume_music = 100
  235.     @volume_sound = 100
  236.     @brightness = 255
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 改變音效音量(單位畫格)
  240.   #--------------------------------------------------------------------------
  241.   def change_sound(value)
  242.     @volume_sound += value
  243.     if @volume_sound > 100
  244.       @volume_sound = 100
  245.     elsif @volume_sound < 1
  246.       @volume_sound = 1
  247.     end
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 改變音樂音量(單位畫格)
  251.   #--------------------------------------------------------------------------
  252.   def change_music(value)
  253.     @volume_music += value
  254.     if @volume_music > 100
  255.       @volume_music = 100
  256.     elsif @volume_music < 1
  257.       @volume_music = 1
  258.     end
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # ● 改變亮度(單位畫格)
  262.   #--------------------------------------------------------------------------
  263.   def change_brightness(value)
  264.     @brightness += value
  265.     if @brightness > 455
  266.       @brightness = 455
  267.     elsif @brightness < 55
  268.       @brightness = 55
  269.     end
  270.   end
  271. end


  272. #encoding:utf-8
  273. #==============================================================================
  274. # ■ Scene_Base
  275. #------------------------------------------------------------------------------
  276. #  游戲中所有 Scene 類(場景類)的父類
  277. #==============================================================================

  278. class Scene_Base
  279.   #--------------------------------------------------------------------------
  280.   # ★ 方法重新定義
  281.   #--------------------------------------------------------------------------
  282.   unless @lctseng_for_system_option_on_Scene_Base_alias
  283.     alias lctseng_for_system_option_on_Scene_Base_for_Start start # 開始處理
  284.     alias lctseng_for_system_option_on_Scene_Base_for_Terminate terminate # 結束處理
  285.     @lctseng_for_system_option_on_Scene_Base_alias = true
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● 開始處理 - 重新定義
  289.   #--------------------------------------------------------------------------
  290.   def start
  291.     set_system_option
  292.     lctseng_for_system_option_on_Scene_Base_for_Start
  293.     create_brightness_viewport
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ● 結束處理 - 重新定義
  297.   #--------------------------------------------------------------------------
  298.   def terminate
  299.     lctseng_for_system_option_on_Scene_Base_for_Terminate
  300.     dispose_brightness_viewport
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● 產生亮度調整用顯示端口
  304.   #--------------------------------------------------------------------------
  305.   def create_brightness_viewport
  306.     @viewport_brightness = Viewport.new
  307.     @viewport_brightness.z = 5000
  308.     adjust_brightness
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # ● 釋放亮度調整用顯示端口
  312.   #--------------------------------------------------------------------------
  313.   def dispose_brightness_viewport
  314.     @viewport_brightness.dispose
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● 執行修正亮度
  318.   #--------------------------------------------------------------------------
  319.   def adjust_brightness
  320.     minus = @system_data.brightness - 255
  321.     @viewport_brightness.tone.red = minus
  322.     @viewport_brightness.tone.green = minus
  323.     @viewport_brightness.tone.blue = minus
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● 取得系統資訊物件
  327.   #--------------------------------------------------------------------------
  328.   def system_data_object
  329.     @system_data
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # ● 重設系統資訊
  333.   #--------------------------------------------------------------------------
  334.   def set_system_option
  335.     @system_data = load_system_data
  336.     Audio.set_music_rate(@system_data.volume_music)
  337.     Audio.set_sound_rate(@system_data.volume_sound)
  338.   end
  339.   #--------------------------------------------------------------------------
  340.   # ● 讀取系統設定資訊
  341.   #--------------------------------------------------------------------------
  342.   def load_system_data
  343.     begin
  344.       return load_system_data_directly
  345.     rescue
  346.       puts "原有資訊不存在,創立新檔案"
  347.       data = write_new_data
  348.       return data
  349.     end
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   # ● 讀取系統設定資訊(直接讀取)
  353.   #--------------------------------------------------------------------------
  354.   def load_system_data_directly
  355.     File.open("SystemOption", "rb") do |file|
  356.       puts "正在讀取原有資訊"
  357.       return Marshal.load(file)
  358.     end
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● 寫入新的系統設定資訊檔案
  362.   #--------------------------------------------------------------------------
  363.   def write_new_data
  364.     new_data = Game_SystemOption.new
  365.     File.open("SystemOption", "wb") do |file|
  366.       Marshal.dump(new_data, file)
  367.     end
  368.     return new_data
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # ● 寫入系統設定資訊檔案
  372.   #--------------------------------------------------------------------------
  373.   def write_system_data
  374.     save_data(system_data_object,"SystemOption")
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● 更新畫面(基礎)
  378.   #--------------------------------------------------------------------------
  379.   def update_basic
  380.     Graphics.update
  381.     Input.update
  382.     update_all_windows
  383.   end
  384. end


  385. #encoding:utf-8
  386. #==============================================================================
  387. # ■ Scene_SystemOption
  388. #------------------------------------------------------------------------------
  389. #  系統選單的管理
  390. #==============================================================================

  391. class Scene_SystemOption < Scene_Base

  392.   #--------------------------------------------------------------------------
  393.   # ● 開始處理
  394.   #--------------------------------------------------------------------------
  395.   def start
  396.     super
  397.     create_back_ground
  398.     create_arrow
  399.     create_bar
  400.     @index = 0
  401.     @stop = true
  402.     @allow_change = true
  403.   end
  404.   #--------------------------------------------------------------------------
  405.   # ● 產生背景
  406.   #--------------------------------------------------------------------------
  407.   def create_back_ground
  408.     @back_ground = Sprite.new(@viewport)
  409.     @back_ground.bitmap = Cache.system("System_Option_Background")
  410.   end
  411.   #--------------------------------------------------------------------------
  412.   # ● 產生箭頭
  413.   #--------------------------------------------------------------------------
  414.   def create_arrow
  415.     @arrow_sprite = Sprite_OptionArrow.new(@viewport)
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ● 產生比率條精靈組
  419.   #--------------------------------------------------------------------------
  420.   def create_bar
  421.     @bar_spritesets = []
  422.     system_data_object.data_rates.each_with_index do |rate,index|
  423.       @bar_spritesets.push(Spriteset_OptionBar.new(index,rate))
  424.     end
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # ● 釋放背景
  428.   #--------------------------------------------------------------------------
  429.   def dispose_back_ground
  430.     @back_ground.bitmap.dispose
  431.     @back_ground.dispose
  432.   end
  433.   #--------------------------------------------------------------------------
  434.   # ● 釋放箭頭
  435.   #--------------------------------------------------------------------------
  436.   def dispose_arrow
  437.     @arrow_sprite.dispose
  438.   end
  439.   #--------------------------------------------------------------------------
  440.   # ● 結束處理
  441.   #--------------------------------------------------------------------------
  442.   def terminate
  443.     dispose_back_ground
  444.     dispose_arrow
  445.     dispose_bar
  446.     super
  447.   end
  448.   #--------------------------------------------------------------------------
  449.   # ● 釋放比率
  450.   #--------------------------------------------------------------------------
  451.   def dispose_bar
  452.     @bar_spritesets.each do |sprite|
  453.       sprite.dispose
  454.     end
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # ● 更新箭頭
  458.   #--------------------------------------------------------------------------
  459.   def update_arrow
  460.     @arrow_sprite.update_pos(@index)
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # ● 更新畫面
  464.   #--------------------------------------------------------------------------
  465.   def update
  466.     super
  467.     update_command
  468.     update_arrow
  469.   end
  470.   #--------------------------------------------------------------------------
  471.   # ● 更新指令
  472.   #--------------------------------------------------------------------------
  473.   def update_command
  474.     if @allow_change
  475.       changing = false
  476.       if Input.press?(:RIGHT)
  477.         changing = true
  478.         @stop = false
  479.         update_right
  480.       elsif Input.press?(:LEFT)
  481.         changing = true
  482.         @stop = false
  483.         update_left
  484.       end
  485.       if !changing
  486.         if !@stop
  487.           @stop = true
  488.           process_on_stop
  489.         end
  490.         if Input.trigger?(:B)
  491.           write_system_data
  492.           return_scene
  493.         end
  494.         if (Input.trigger?(:C) && @index == 3 )
  495.           system_data_object.reset
  496.           process_on_stop
  497.           update_when_change
  498.           adjust_brightness
  499.         end
  500.         if Input.repeat?(:UP)
  501.           @index -= 1
  502.           if @index < 0
  503.             @index = 3
  504.           end
  505.           moving = true
  506.         elsif Input.repeat?(:DOWN)
  507.           @index += 1
  508.           @index %= 4
  509.           moving = true
  510.         end
  511.       end
  512.     end
  513.   end
  514.   #--------------------------------------------------------------------------
  515.   # ● 停止時的處理
  516.   #--------------------------------------------------------------------------
  517.   def process_on_stop
  518.     case @index
  519.     when 0
  520.       Audio.set_music_rate_with_effect(system_data_object.volume_music)
  521.     when 1
  522.       Audio.set_sound_rate_with_effect(system_data_object.volume_sound)
  523.     when 3
  524.       Audio.set_music_rate_with_effect(system_data_object.volume_music)
  525.       Audio.set_sound_rate_with_effect(system_data_object.volume_sound)
  526.     end
  527.     puts "執行停止"
  528.     write_system_data
  529.     puts "三項資料:#{system_data_object.data_array}"
  530.   end
  531.   #--------------------------------------------------------------------------
  532.   # ● 更換比率後的更新
  533.   #--------------------------------------------------------------------------
  534.   def update_when_change
  535.     if @index > 2
  536.       3.times do |index|
  537.         @bar_spritesets[index].update_rate(system_data_object.data_rates[index])
  538.       end
  539.     else
  540.       @bar_spritesets[@index].update_rate(system_data_object.data_rates[@index])
  541.     end
  542.    
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # ● 更新右移
  546.   #--------------------------------------------------------------------------
  547.   def update_right
  548.     case @index
  549.     when 0
  550.       system_data_object.change_music(1)
  551.     when 1
  552.       system_data_object.change_sound(1)
  553.     when 2
  554.       system_data_object.change_brightness(1)
  555.       adjust_brightness
  556.     end
  557.     update_when_change
  558.   end
  559.   #--------------------------------------------------------------------------
  560.   # ● 更新左移
  561.   #-------------------------------------------------------------------------
  562.   def update_left
  563.     case @index
  564.     when 0
  565.       system_data_object.change_music(-1)
  566.     when 1
  567.       system_data_object.change_sound(-1)
  568.     when 2
  569.       system_data_object.change_brightness(-1)
  570.       adjust_brightness
  571.     end
  572.     update_when_change
  573.   end
  574. end


  575. #encoding:utf-8
  576. #==============================================================================
  577. # ■ Spriteset_OptionBar
  578. #      系統設定裡的比率條精靈組
  579. #==============================================================================

  580. class Spriteset_OptionBar
  581.   #--------------------------------------------------------------------------
  582.   # ● 初始化對象
  583.   #--------------------------------------------------------------------------
  584.   def initialize(index,rate)
  585.     @index = index
  586.     @rate = rate
  587.     create_viewport
  588.     create_sprite
  589.   end
  590.   #--------------------------------------------------------------------------
  591.   # ● 取得顯示端口用的矩形
  592.   #--------------------------------------------------------------------------
  593.   def get_viewport_rect
  594.     ry = Lctseng::SystemOption::Bar_Y[@index]
  595.     if !ry
  596.       ry = 0
  597.     end
  598.     return Rect.new(Lctseng::SystemOption::Bar_X,ry,Lctseng::SystemOption::Bar_Width,Lctseng::SystemOption::Bar_Height)
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # ● 產生顯示端口
  602.   #--------------------------------------------------------------------------
  603.   def create_viewport
  604.     @viewport = Viewport.new(get_viewport_rect)
  605.     @viewport.rect.width = Lctseng::SystemOption::Bar_Width * @rate
  606.     @viewport.z = 200
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # ● 產生精靈
  610.   #--------------------------------------------------------------------------
  611.   def create_sprite
  612.     @sprite = Sprite.new(@viewport)
  613.     @sprite.bitmap = Cache.system("System_Option_Bar")
  614.   end
  615.   #--------------------------------------------------------------------------
  616.   # ● 更新比率
  617.   #--------------------------------------------------------------------------
  618.   def update_rate(rate)
  619.     @rate = rate
  620.     update_viewport
  621.   end
  622.   #--------------------------------------------------------------------------
  623.   # ● 更新顯示端口
  624.   #--------------------------------------------------------------------------
  625.   def update_viewport
  626.     @viewport.rect.width = Lctseng::SystemOption::Bar_Width * @rate
  627.   end
  628.   #--------------------------------------------------------------------------
  629.   # ● 釋放精靈
  630.   #--------------------------------------------------------------------------
  631.   def dispose_sprite
  632.     @sprite.dispose
  633.   end
  634.   #--------------------------------------------------------------------------
  635.   # ● 釋放顯示端口
  636.   #--------------------------------------------------------------------------
  637.   def dispose_viewport
  638.     @viewport.dispose
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # ● 釋放
  642.   #--------------------------------------------------------------------------
  643.   def dispose
  644.     dispose_sprite
  645.     dispose_viewport
  646.   end
  647. end


  648. #encoding:utf-8
  649. #==============================================================================
  650. # ■ Sprite_OptionArrow
  651. #      系統設定裡的箭頭精靈
  652. #==============================================================================

  653. class Sprite_OptionArrow < Sprite_Base
  654.   #--------------------------------------------------------------------------
  655.   # ● 初始化對象
  656.   #--------------------------------------------------------------------------
  657.   def initialize(viewport = nil)
  658.     super(viewport)
  659.     self.bitmap = Cache.system("System_Option_Arrow")
  660.     self.x = Lctseng::SystemOption::ARROW_X
  661.     update_pos(0)
  662.   end
  663.   #--------------------------------------------------------------------------
  664.   # ● 更新畫面
  665.   #--------------------------------------------------------------------------
  666.   def update
  667.     super
  668.   end
  669.   #--------------------------------------------------------------------------
  670.   # ● 釋放
  671.   #--------------------------------------------------------------------------
  672.   def dispose
  673.     self.bitmap.dispose if self.bitmap
  674.     super
  675.   end
  676.   #--------------------------------------------------------------------------
  677.   # ● 更新位置
  678.   #--------------------------------------------------------------------------
  679.   def update_pos(index)
  680.     ry = Lctseng::SystemOption::ARROW_Y[index]
  681.     if !ry
  682.       ry = 0
  683.     end
  684.     self.y =  ry
  685.   end
  686. end
复制代码


  1. #encoding:utf-8

  2. =begin
  3. *******************************************************************************************

  4.    * Lctseng - 追加系統設定選單*

  5.                        for RGSS3

  6.         Ver 1.00   2013.09.02

  7.    原作者:魂(Lctseng),巴哈姆特論壇ID:play123
  8.    原文發表於:巴哈姆特RPG製作大師哈拉版

  9.    轉載請保留此標籤

  10.    個人小屋連結:[url]http://home.gamer.com.tw/homeindex.php?owner=play123[/url]
  11.    
  12.    需求前置腳本:Lctseng - 系統設定畫面
  13.    請將此腳本至於該腳本底下
  14.    
  15.    
  16.    主要功能:
  17.                        一、將系統設定畫面添加到選單指令中

  18.    更新紀錄:
  19.     Ver 1.00 :
  20.     日期:2013.09.02
  21.     摘要:一、最初版本



  22.     撰寫摘要:一、此腳本修改或重新定義以下類別:
  23.                           1.Scene_Menu
  24.                           2.Window_MenuCommand
  25.                           
  26.                           

  27. *******************************************************************************************

  28. =end

  29. #*******************************************************************************************
  30. #
  31. #   請勿修改從這裡以下的程式碼,除非你知道你在做什麼!
  32. #   DO NOT MODIFY UNLESS YOU KNOW WHAT TO DO !
  33. #
  34. #*******************************************************************************************

  35. #--------------------------------------------------------------------------
  36. # ★ 紀錄腳本資訊
  37. #--------------------------------------------------------------------------
  38. if !$lctseng_scripts  
  39.   $lctseng_scripts = {}
  40. end
  41. ## 檢查前置腳本
  42. if !$lctseng_scripts[:system_option]
  43.   msgbox("沒有發現前置腳本:Lctseng - 系統設定畫面\n或者是腳本位置錯誤!\n程式即將關閉")
  44.   exit
  45. end
  46. $lctseng_scripts[:menu_system_option] = "1.00"

  47. puts "載入腳本:Lctseng - 追加系統設定選單,版本:#{$lctseng_scripts[:menu_system_option]}"

  48. #encoding:utf-8
  49. #==============================================================================
  50. # ■ Scene_Menu
  51. #------------------------------------------------------------------------------
  52. #  菜單畫面
  53. #==============================================================================

  54. class Scene_Menu
  55.   #--------------------------------------------------------------------------
  56.   # ★ 方法重新定義
  57.   #--------------------------------------------------------------------------
  58.   unless @lctseng_for_system_option_on_Scene_Menu_alias
  59.     alias lctseng_for_system_option_on_Scene_Menu_for_Create_command_window create_command_window # 生成指令窗口
  60.     @lctseng_for_system_option_on_Scene_Menu_alias = true
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● 生成指令窗口 - 重新定義
  64.   #--------------------------------------------------------------------------
  65.   def create_command_window(*args,&block)
  66.     lctseng_for_system_option_on_Scene_Menu_for_Create_command_window(*args,&block)
  67.     @command_window.set_handler(:systemOption,    method(:command_system))
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● 指令“系統”
  71.   #--------------------------------------------------------------------------
  72.   def command_system
  73.     SceneManager.call(Scene_SystemOption)
  74.   end

  75. end


  76. #encoding:utf-8
  77. #==============================================================================
  78. # ■ Window_MenuCommand
  79. #------------------------------------------------------------------------------
  80. #  菜單畫面中顯示指令的窗口
  81. #==============================================================================

  82. class Window_MenuCommand < Window_Command
  83.   #--------------------------------------------------------------------------
  84.   # ★ 方法重新定義
  85.   #--------------------------------------------------------------------------
  86.   unless @lctseng_for_system_option_on_Window_MenuCommand_alias
  87.     alias lctseng_for_system_option_on_Window_MenuCommand_for_Add_original_commands add_original_commands
  88.     @lctseng_for_system_option_on_Window_MenuCommand_alias = true
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ● 獨自添加指令用 - 重新定義
  92.   #--------------------------------------------------------------------------
  93.   def add_original_commands(*args,&block)
  94.     lctseng_for_system_option_on_Window_MenuCommand_for_Add_original_commands(*args,&block)
  95.     add_command("系統選項", :systemOption, true)
  96.   end

  97. end
复制代码




填坑中
梦石
0
星屑
50
在线时间
21 小时
注册时间
2015-12-31
回帖
9
发表于 2016-1-6 10:10:49 | 显示全部楼层
1.怎么更改菜单背景的不透明度?/怎么去掉菜单背景?
菜单位于脚本Window_MenuCommand,它是个窗口(隔了几代继承于Window)。
凡是窗口的,关于透明度有下面三个参数(为Window的属性):
1、opacity (窗口不透明度,取值0-255,不含内容)
2、back_opacity(窗口背景不透明度,取值0-255,不含内容不含边框)
3、contents_opacity (窗口内容不透明度,取值0-255)
1(opacity )和2(back_opacity)的透明度改变时候不会影响窗口内容(contents_opacity )的透明度。
那么,只要对需要改变的Window_MenuCommand实例设置所需参数即可。

2.如果我想从某个事件直接连接到外站脚本的功用,我该填什么?
知道它的运作原理就会明白。
首先要知道有个类是Window_Command,菜单窗口(Window_MenuCommand)的父类。
它维护了一个重要的变量:@list。这是个数组,便是用它来管理指令的。
同样,add_command(添加指令方法)也在这个类中定义,他就是往@list中添加了一个东西(那个东西叫哈希表)。
————————————————
接下来查看Window_MenuCommand类,他是上面Window_Command的子类。它的主要作用就是调用一系列的add_command方法。
是的,菜单上看到的物品、技能等等字样第一步都是在这里添加的。顺便提一下,这只是添加入一个@list数组而已,这些字是怎么会显示到菜单上的呢?可以看到Window_Command中的draw_item方法,正是它从@list中找出了“物品、技能”等等这些名字画到了菜单窗口上,他在窗口刷新(父类中)时被调用。
————————————————
现在说明另一个哈希表@handler,他被定义在Window_Command的父类Window_Selectable中,他有一个相关方法set_handler,便是向@handler中添加一对值,他会在包含Window_Command子类实例的场景中调用。以菜单场景(Scene_Menu)为例,他在create_command_window方法调用了一系列set_handler给“物品、技能”等等这些字样绑定方法,熟悉编程的可以把它理解成是个存放函数指针的东西。之所以这些方法要在场景中绑定,是因为这些方法往往跟场景中的其他内容有关,与窗口本身无关。
————————————————
说道这里你一定感到奇怪:@list和@handler是两个不同的变量,甚至定义在不同类当中,为什么添加指令是@list的操作,而绑定方法是对@handler操作,他们是怎么联系起来的?答案是index变量,他被定义在Window_Selectable中,他是记录光标位置的值,按下上下左右翻页,它的值就会变。Window_Command中的current_data就是根据这个index获取@list的内容,从而得到current_symbol,从而在call_ok_handler方法(按确定键调用)找到@handler与之绑定的方法执行。

点评

………………回答这么仔细,给跪了  发表于 2016-1-6 14:15

评分

参与人数 1梦石 +1 收起 理由
VIPArcher + 1 塞糖

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部