Project1
标题:
求一个音量调整脚本
[打印本页]
作者:
⋛冰⋛
时间:
2011-2-27 12:31
标题:
求一个音量调整脚本
求助啊。。我是脚本小白。
作者:
⋛冰⋛
时间:
2011-2-27 12:47
当然是做游戏用啦……
作者:
Wind2010
时间:
2011-2-27 15:45
class Game_System
attr_accessor :music_num
attr_accessor :sound_num
attr_accessor :auto_save
alias shizi_initialize initialize
def initialize
shizi_initialize
@music_num = 100
@sound_num = 100
@auto_save = false
end
def bgm_play(bgm)
@playing_bgm = bgm
if bgm != nil and bgm.name != ""
Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume * @music_num / 100, bgm.pitch)
else
Audio.bgm_stop
end
Graphics.frame_reset
end
def bgs_play(bgs)
@playing_bgs = bgs
if bgs != nil and bgs.name != ""
Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume * @music_num / 100, bgs.pitch)
else
Audio.bgs_stop
end
Graphics.frame_reset
end
def me_play(me)
if me != nil and me.name != ""
Audio.me_play("Audio/ME/" + me.name, me.volume * @sound_num / 100, me.pitch)
else
Audio.me_stop
end
Graphics.frame_reset
end
def se_play(se)
if se != nil and se.name != ""
Audio.se_play("Audio/SE/" + se.name, se.volume * @sound_num / 100, se.pitch)
end
end
end
class Scene_Select
def main
@screen = Spriteset_Map.new
s1 = " 音乐 "
s2 = " 音效 "
s3 = "自动存档"
@wd1 = Window_Command.new(128,[s1,s2,s3])
@wd1.x = 158
@wd1.y = 176
@wd2 = Window_Base.new(0,0,324,128)
@wd2.contents = Bitmap.new(292,96)
@wd2.x = 158
@wd2.y = 176
@wd2.active = false
wd2_refresh
@wd3 = Window_Base.new(0,0,324,128)
@wd3.contents = Bitmap.new(292,96)
@wd3.x = 158
@wd3.y = 176
wd3_refresh
@wd4 = Window_Base.new(0,0,324,128)
@wd4.contents = Bitmap.new(292,96)
@wd4.x = 158
@wd4.y = 176
@wd4.active = false
wd4_refresh
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@screen.dispose
@wd1.dispose
@wd2.dispose
@wd3.dispose
@wd4.dispose
end
def update
$windspeed.update
if @wd2.active
return music_update
end
if @wd4.active
return sound_update
end
@wd1.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @wd1.index
when 0
@wd2.active = true
@wd1.active = false
when 1
@wd4.active = true
@wd1.active = false
when 2
$game_system.auto_save ? $game_system.auto_save = false : $game_system.auto_save = true
wd3_refresh
end
end
end
def wd2_refresh
@wd2.contents.clear
@wd2.contents.fill_rect(128,14,102,4,Color.new(255,255,255,255))
@wd2.contents.fill_rect(129,15,100,2,Color.new(25,25,255,255))
@wd2.contents.fill_rect(126+$game_system.music_num,11,4,10,Color.new(255,255,255,255))
@wd2.contents.draw_text(235,0,100,32,$game_system.music_num.to_s)
end
def wd4_refresh
@wd4.contents.clear
@wd4.contents.fill_rect(128,46,102,4,Color.new(255,255,255,255))
@wd4.contents.fill_rect(129,47,100,2,Color.new(25,25,255,255))
@wd4.contents.fill_rect(126+$game_system.sound_num,43,4,10,Color.new(255,255,255,255))
@wd4.contents.draw_text(235,32,100,32,$game_system.sound_num.to_s)
end
def wd3_refresh
@wd3.contents.clear
$game_system.auto_save ? @wd3.contents.draw_text(128,64,164,32,"开",1) : @wd3.contents.draw_text(128,64,164,32,"关",1)
end
def music_update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@wd2.active = false
@wd1.active = true
end
if Mouse.press?(Mouse::LEFT)
mouse_x, mouse_y = Mouse.get_mouse_pos
if mouse_x >= 302 and mouse_x <= 402 and mouse_y >= 203 and mouse_y <= 213
@music = mouse_x - 302
if @music != $game_system.music_num
$game_system.music_num = @music
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
wd2_refresh
end
end
end
if Input.repeat?(Input::LEFT) and $game_system.music_num > 0
Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
$game_system.music_num -= 1
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
wd2_refresh
end
if Input.repeat?(Input::RIGHT) and $game_system.music_num < 100
Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
$game_system.music_num += 1
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
wd2_refresh
end
end
def sound_update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@wd4.active = false
@wd1.active = true
end
if Mouse.press?(Mouse::LEFT)
mouse_x, mouse_y = Mouse.get_mouse_pos
if mouse_x >= 302 and mouse_x <= 402 and mouse_y >= 235 and mouse_y <= 245
@sound = mouse_x - 302
if @sound != $game_system.sound_num
Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
$game_system.sound_num = @sound
wd4_refresh
end
end
end
if Input.repeat?(Input::LEFT) and $game_system.sound_num > 0
Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
$game_system.sound_num -= 1
wd4_refresh
end
if Input.repeat?(Input::RIGHT) and $game_system.sound_num < 100
Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
$game_system.sound_num += 1
wd4_refresh
end
end
end
class Scene_Map
alias shizixd update
def update
shizixd
auto_save if $game_system.auto_save
end
def auto_save
cundang if $game_variables[1] == 0
if $game_variables[1] != 0
filename = "Save#{$game_variables[1]}.rxdata"
file = File.open(filename, "wb")
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
file.close
end
end
end
复制代码
存档顺序是被打乱的XD
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1