赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 0 |
经验 | 0 |
最后登录 | 2013-3-28 |
在线时间 | 20 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 248
- 在线时间
- 20 小时
- 注册时间
- 2012-8-15
- 帖子
- 1
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 kikilolo 于 2013-3-16 14:51 编辑
在这帖子引用了好用的音量调节脚本,
http://rpg.blue/forum.php?mod=viewthread&tid=84008
但是这脚本是属于Scene_System 类...
有办法可以更改成独立的类别嗎?例如(Scene_Music01)
让这个脚本可以直接调用参数就呼叫出音量调节界面的方法吗?
我的系统是点击鼠标右键就可以返回的,安装了又没办法点击右键返回画面。。。
脚本中有这些字段,但这都是不需要用到的。。。
因为只是希望可以鼠标左键点选一个图片,就进入音量调节介面,
点选鼠标右键就可以立即返回原画面。
s1 = Vocab::item
s2 = Vocab::skill
s3 = Vocab::equip
s4 = Vocab::status
s5 = Vocab::save
s6 = OPTION_NAME
s7 = Vocab::game_end
不晓得应该如何更改这个脚本。。在此求教高手!谢谢
脚本: 应用脚本
#============================================================================== # 菜单中添加系统音量设置 by 沉影不器 #------------------------------------------------------------------------------ # 功能: 在菜单选项中添加[系统音量]选项,可调节: # 背景音乐.背景声效.音乐和声效 # 说明: 两个脚本(包括slider控件脚本)插入到Main之前 # 在脚本第10行设定初始化系统音量 # 在脚本第11行设定系统音量各自的名称 # 在脚本第12行设定菜单中新增选项的名称 #============================================================================== $volume = [60,60,60,60] # 初始化系统音量 VOLUME_NAME = ["背景音乐","背景声效","音乐","声效"] # 各系统音量名称 OPTION_NAME = "系统音量" # 菜单中新增选项名称 #============================================================================== # ■ Scene_System #============================================================================== class Scene_System < Scene_Base #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super create_menu_background @viewport = Viewport.new(0, 0, 544, 416) @base_window = Window_Base.new(64, 78, 416, 280) @base_window.viewport = @viewport @base_window.active = false # 处理帮助窗体 @help_window = Window_Help.new @help_window.viewport = @viewport @help_window.x = 64 @help_window.y = 22 @help_window.width = 416 @help_window.contents = Bitmap.new(416 - 32, 56 - 32) # slider窗体 @slider_window = [] for i in 0..3 @slider_window[i] = Window_Slider.new(64, 78+48*i, 280, 96) @slider_window[i].setup(VOLUME_NAME[i],32,32,120,8,100,0,0,1) # 绑定变量 @slider_window[i].value = $volume[i] @slider_window[i].active = true @slider_window[i].opacity = 0 @slider_window[i].contents_opacity = 128 end @index = 0 end #-------------------------------------------------------------------------- # ● 结束处理 #-------------------------------------------------------------------------- def terminate super dispose_menu_background @viewport.dispose @help_window.dispose @base_window.dispose for i in 0..3 @slider_window[i].dispose end end #-------------------------------------------------------------------------- # ● 返回至原来的画面 #-------------------------------------------------------------------------- def return_scene $scene = Scene_Menu.new(5) end #-------------------------------------------------------------------------- # ● 更新画面 #-------------------------------------------------------------------------- def slider_switch if Input.repeat?(Input::UP) @index -= 1 if @index > 0 Sound.play_cursor end if Input.repeat?(Input::DOWN) @index += 1 if @index < 3 Sound.play_cursor end for i in 0..3 @slider_window[i].active = false @slider_window[i].contents_opacity = 128 end @slider_window[@index].active = true @slider_window[@index].contents_opacity = 255 text = "更改" + @slider_window[@index].name + "的音量。" @help_window.set_text(text) end #-------------------------------------------------------------------------- # ● 更新画面 #-------------------------------------------------------------------------- def update super if Input.trigger?(Input::B) Sound.play_cancel return_scene end update_menu_background slider_switch @slider_window[@index].update @help_window.update # 绑定变量 $volume[@index] = @slider_window[@index].value end end #============================================================================== # ■ Scene_Menu #============================================================================== class Scene_Menu < Scene_Base #-------------------------------------------------------------------------- # ● 生成指令窗口 #-------------------------------------------------------------------------- def create_command_window s1 = Vocab::item s2 = Vocab::skill s3 = Vocab::equip s4 = Vocab::status s5 = Vocab::save s6 = OPTION_NAME s7 = Vocab::game_end @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7]) @command_window.index = @menu_index if $game_party.members.size == 0 # 同伴人数为 0 的情况下 @command_window.draw_item(0, false) # 物品无效化 @command_window.draw_item(1, false) # 特技无效化 @command_window.draw_item(2, false) # 装备无效化 @command_window.draw_item(3, false) # 状态无效化 end if $game_system.save_disabled # 禁止存档的情况下 @command_window.draw_item(4, false) # 存档无效化 end end #-------------------------------------------------------------------------- # ● 更新指令选择 #-------------------------------------------------------------------------- def update_command_selection if Input.trigger?(Input::B) Sound.play_cancel $scene = Scene_Map.new elsif Input.trigger?(Input::C) if $game_party.members.size == 0 and @command_window.index < 4 Sound.play_buzzer return elsif $game_system.save_disabled and @command_window.index == 4 Sound.play_buzzer return end Sound.play_decision case @command_window.index when 0 # 物品 $scene = Scene_Item.new when 1,2,3 # 特技、装备、状态 start_actor_selection when 4 # 存档 $scene = Scene_File.new(true, false, false) when 5 # 系统设置 $scene = Scene_System.new when 6 # 游戏结束 $scene = Scene_End.new end end end end #============================================================================== # ■ 背景音乐 #============================================================================== module RPG class BGM < AudioFile @@last = BGM.new def play if @name.empty? Audio.bgm_stop @@last = BGM.new else Audio.bgm_play("Audio/BGM/" + @name, @volume * $volume[0]/100 , @pitch) @@last = self end end end #============================================================================== # ■ 背景声效 #============================================================================== class BGS < AudioFile @@last = BGS.new def play if @name.empty? Audio.bgs_stop @@last = BGS.new else Audio.bgs_play("Audio/BGS/" + @name, @volume * $volume[1]/100, @pitch) @@last = self end end end #============================================================================== # ■ 音乐 #============================================================================== class ME < AudioFile def play if @name.empty? Audio.me_stop else Audio.me_play("Audio/ME/" + @name, @volume * $volume[2]/100, @pitch) end end end #============================================================================== # ■ 声效 #============================================================================== class SE < AudioFile def play unless @name.empty? Audio.se_play("Audio/SE/" + @name, @volume * $volume[3]/100, @pitch) end end end end
#==============================================================================
# 菜单中添加系统音量设置 by 沉影不器
#------------------------------------------------------------------------------
# 功能: 在菜单选项中添加[系统音量]选项,可调节:
# 背景音乐.背景声效.音乐和声效
# 说明: 两个脚本(包括slider控件脚本)插入到Main之前
# 在脚本第10行设定初始化系统音量
# 在脚本第11行设定系统音量各自的名称
# 在脚本第12行设定菜单中新增选项的名称
#==============================================================================
$volume = [60,60,60,60] # 初始化系统音量
VOLUME_NAME = ["背景音乐","背景声效","音乐","声效"] # 各系统音量名称
OPTION_NAME = "系统音量" # 菜单中新增选项名称
#==============================================================================
# ■ Scene_System
#==============================================================================
class Scene_System < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_menu_background
@viewport = Viewport.new(0, 0, 544, 416)
@base_window = Window_Base.new(64, 78, 416, 280)
@base_window.viewport = @viewport
@base_window.active = false
# 处理帮助窗体
@help_window = Window_Help.new
@help_window.viewport = @viewport
@help_window.x = 64
@help_window.y = 22
@help_window.width = 416
@help_window.contents = Bitmap.new(416 - 32, 56 - 32)
# slider窗体
@slider_window = []
for i in 0..3
@slider_window[i] = Window_Slider.new(64, 78+48*i, 280, 96)
@slider_window[i].setup(VOLUME_NAME[i],32,32,120,8,100,0,0,1)
# 绑定变量
@slider_window[i].value = $volume[i]
@slider_window[i].active = true
@slider_window[i].opacity = 0
@slider_window[i].contents_opacity = 128
end
@index = 0
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@viewport.dispose
@help_window.dispose
@base_window.dispose
for i in 0..3
@slider_window[i].dispose
end
end
#--------------------------------------------------------------------------
# ● 返回至原来的画面
#--------------------------------------------------------------------------
def return_scene
$scene = Scene_Menu.new(5)
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def slider_switch
if Input.repeat?(Input::UP)
@index -= 1 if @index > 0
Sound.play_cursor
end
if Input.repeat?(Input::DOWN)
@index += 1 if @index < 3
Sound.play_cursor
end
for i in 0..3
@slider_window[i].active = false
@slider_window[i].contents_opacity = 128
end
@slider_window[@index].active = true
@slider_window[@index].contents_opacity = 255
text = "更改" + @slider_window[@index].name + "的音量。"
@help_window.set_text(text)
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
end
update_menu_background
slider_switch
@slider_window[@index].update
@help_window.update
# 绑定变量
$volume[@index] = @slider_window[@index].value
end
end
#==============================================================================
# ■ Scene_Menu
#==============================================================================
class Scene_Menu < Scene_Base
#--------------------------------------------------------------------------
# ● 生成指令窗口
#--------------------------------------------------------------------------
def create_command_window
s1 = Vocab::item
s2 = Vocab::skill
s3 = Vocab::equip
s4 = Vocab::status
s5 = Vocab::save
s6 = OPTION_NAME
s7 = Vocab::game_end
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
@command_window.index = @menu_index
if $game_party.members.size == 0 # 同伴人数为 0 的情况下
@command_window.draw_item(0, false) # 物品无效化
@command_window.draw_item(1, false) # 特技无效化
@command_window.draw_item(2, false) # 装备无效化
@command_window.draw_item(3, false) # 状态无效化
end
if $game_system.save_disabled # 禁止存档的情况下
@command_window.draw_item(4, false) # 存档无效化
end
end
#--------------------------------------------------------------------------
# ● 更新指令选择
#--------------------------------------------------------------------------
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
if $game_party.members.size == 0 and @command_window.index < 4
Sound.play_buzzer
return
elsif $game_system.save_disabled and @command_window.index == 4
Sound.play_buzzer
return
end
Sound.play_decision
case @command_window.index
when 0 # 物品
$scene = Scene_Item.new
when 1,2,3 # 特技、装备、状态
start_actor_selection
when 4 # 存档
$scene = Scene_File.new(true, false, false)
when 5 # 系统设置
$scene = Scene_System.new
when 6 # 游戏结束
$scene = Scene_End.new
end
end
end
end
#==============================================================================
# ■ 背景音乐
#==============================================================================
module RPG
class BGM < AudioFile
@@last = BGM.new
def play
if @name.empty?
Audio.bgm_stop
@@last = BGM.new
else
Audio.bgm_play("Audio/BGM/" + @name, @volume * $volume[0]/100 , @pitch)
@@last = self
end
end
end
#==============================================================================
# ■ 背景声效
#==============================================================================
class BGS < AudioFile
@@last = BGS.new
def play
if @name.empty?
Audio.bgs_stop
@@last = BGS.new
else
Audio.bgs_play("Audio/BGS/" + @name, @volume * $volume[1]/100, @pitch)
@@last = self
end
end
end
#==============================================================================
# ■ 音乐
#==============================================================================
class ME < AudioFile
def play
if @name.empty?
Audio.me_stop
else
Audio.me_play("Audio/ME/" + @name, @volume * $volume[2]/100, @pitch)
end
end
end
#==============================================================================
# ■ 声效
#==============================================================================
class SE < AudioFile
def play
unless @name.empty?
Audio.se_play("Audio/SE/" + @name, @volume * $volume[3]/100, @pitch)
end
end
end
end
slider控件脚本
#============================================================================== # 添加slider控件的rm窗体 by 沉影不器 #------------------------------------------------------------------------------ # 功能描述: ① 一个可使用类似C++的slider控件的窗体 # ② 通过slider控件的value输出与指定变量绑定 # ③ 方便脚本用户自定义样式,可在[● 样式1]之后随意添加新样式 # # 输入与输出: ① 允许自定义的项目包括: # 名称、坐标、宽高、数据最大值、每次改变量、 # 初始化时显示的值(value)、样式 # ② 控件输出包括: # 名称、数据最大值、每次改变量、当前变量值(value) #------------------------------------------------------------------------------ class Window_Slider < Window_Base #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_reader :name # 名称 attr_reader :max # 最大值 attr_reader :change # 改变量 attr_reader :value # 当前值 #-------------------------------------------------------------------------- # ● 设置 保存参数 # name : 名称 # x : X 坐标 # y : Y 坐标 # w : 宽 # h : 高 # max : 最大值 # change : 改变量 # value : 当前值 # style : 样式 #-------------------------------------------------------------------------- def setup(name, x, y, w, h = 10, max = 100, change = 1, value = 0, style = 0) @name = name @x = x @y = y @w = w @h = h @max = max @value = value @style = style @change = change > 0 ? change : 1 draw_slider(value) end #-------------------------------------------------------------------------- # ● 描绘 slider # value : 当前值 #-------------------------------------------------------------------------- def draw_slider(value) case @style when 0 style_0(value) when 1 style_1(value) end end #-------------------------------------------------------------------------- # ● 样式0 # value : 当前值 #-------------------------------------------------------------------------- def style_0(value) slide_x = (@w - @h/2) * value / @max color1 = Color.new(0, 0, 0, 255) color2 = Color.new(192, 192, 192, 255) # 清理 self.contents.clear # 描绘名称 self.contents.draw_text(@x, @y, @w, 24, @name) # 描绘当前值 self.contents.draw_text(@x+@w-64, @y, 64, 24, value.to_s, 2) # 填充 self.contents.fill_rect(@x, @y+23+@h/2, @w, 2, color1) self.contents.fill_rect(@x+slide_x, @y+24, @h/2, @h, color2) end #-------------------------------------------------------------------------- # ● 样式1 # value : 当前值 #-------------------------------------------------------------------------- def style_1(value) width = @w * value / @max color1 = Color.new(0, 0, 0, 255) color2 = Color.new(192, 64, 64, 255) # 清理 self.contents.clear # 描绘名称 self.contents.draw_text(@x, @y, @w, 24, @name) # 描绘当前值 self.contents.draw_text(@x+@w-64, @y, 64, 24, value.to_s, 2) # 填充 self.contents.fill_rect(@x-1, @y+23, @w+2, @h+2, color1) self.contents.fill_rect(@x, @y+24, width, @h, color2) end #-------------------------------------------------------------------------- # ● 更改当前值 # value : 当前值 #-------------------------------------------------------------------------- def value=(value) @value = value draw_slider(value) end #-------------------------------------------------------------------------- # ● 输入刷新 #-------------------------------------------------------------------------- def update if Input.repeat?(Input::RIGHT) if @value < @max - @change @value += @change else @value = @max end draw_slider(@value) Sound.play_decision end if Input.repeat?(Input::LEFT) if @value > @change @value -= @change else @value = 0 end draw_slider(@value) Sound.play_decision end end end
#==============================================================================
# 添加slider控件的rm窗体 by 沉影不器
#------------------------------------------------------------------------------
# 功能描述: ① 一个可使用类似C++的slider控件的窗体
# ② 通过slider控件的value输出与指定变量绑定
# ③ 方便脚本用户自定义样式,可在[● 样式1]之后随意添加新样式
#
# 输入与输出: ① 允许自定义的项目包括:
# 名称、坐标、宽高、数据最大值、每次改变量、
# 初始化时显示的值(value)、样式
# ② 控件输出包括:
# 名称、数据最大值、每次改变量、当前变量值(value)
#------------------------------------------------------------------------------
class Window_Slider < Window_Base
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :name # 名称
attr_reader :max # 最大值
attr_reader :change # 改变量
attr_reader :value # 当前值
#--------------------------------------------------------------------------
# ● 设置 保存参数
# name : 名称
# x : X 坐标
# y : Y 坐标
# w : 宽
# h : 高
# max : 最大值
# change : 改变量
# value : 当前值
# style : 样式
#--------------------------------------------------------------------------
def setup(name, x, y, w, h = 10, max = 100, change = 1, value = 0, style = 0)
@name = name
@x = x
@y = y
@w = w
@h = h
@max = max
@value = value
@style = style
@change = change > 0 ? change : 1
draw_slider(value)
end
#--------------------------------------------------------------------------
# ● 描绘 slider
# value : 当前值
#--------------------------------------------------------------------------
def draw_slider(value)
case @style
when 0
style_0(value)
when 1
style_1(value)
end
end
#--------------------------------------------------------------------------
# ● 样式0
# value : 当前值
#--------------------------------------------------------------------------
def style_0(value)
slide_x = (@w - @h/2) * value / @max
color1 = Color.new(0, 0, 0, 255)
color2 = Color.new(192, 192, 192, 255)
# 清理
self.contents.clear
# 描绘名称
self.contents.draw_text(@x, @y, @w, 24, @name)
# 描绘当前值
self.contents.draw_text(@x+@w-64, @y, 64, 24, value.to_s, 2)
# 填充
self.contents.fill_rect(@x, @y+23+@h/2, @w, 2, color1)
self.contents.fill_rect(@x+slide_x, @y+24, @h/2, @h, color2)
end
#--------------------------------------------------------------------------
# ● 样式1
# value : 当前值
#--------------------------------------------------------------------------
def style_1(value)
width = @w * value / @max
color1 = Color.new(0, 0, 0, 255)
color2 = Color.new(192, 64, 64, 255)
# 清理
self.contents.clear
# 描绘名称
self.contents.draw_text(@x, @y, @w, 24, @name)
# 描绘当前值
self.contents.draw_text(@x+@w-64, @y, 64, 24, value.to_s, 2)
# 填充
self.contents.fill_rect(@x-1, @y+23, @w+2, @h+2, color1)
self.contents.fill_rect(@x, @y+24, width, @h, color2)
end
#--------------------------------------------------------------------------
# ● 更改当前值
# value : 当前值
#--------------------------------------------------------------------------
def value=(value)
@value = value
draw_slider(value)
end
#--------------------------------------------------------------------------
# ● 输入刷新
#--------------------------------------------------------------------------
def update
if Input.repeat?(Input::RIGHT)
if @value < @max - @change
@value += @change
else
@value = @max
end
draw_slider(@value)
Sound.play_decision
end
if Input.repeat?(Input::LEFT)
if @value > @change
@value -= @change
else
@value = 0
end
draw_slider(@value)
Sound.play_decision
end
end
end
|
|