게임 플레이중 음량 설정 RGSS2 DAIpage v1.0
●기능과 사용법
·게임중에F5키를 누르면 음량 조정을 할 수 있습니다.
·BGM(와)과BGS·ME(와)과SE(을)를 각각 설정할 수 있으므로 편리할지도 모릅니다.
● 재정의 하고 있는 클래스 명과 모듈명
module RPG,Game_System(을)를 앨리어스(alias).
=end
#==============================================================================
# ■ Volume_Config
#==============================================================================
module Volume_Config
#--------------------------------------------------------------------------
# ● 프레임 갱신
#--------------------------------------------------------------------------
def update
if Input.trigger?(Input::F5)
Sound.play_decision
create_volume_back_sprite
create_volume_gauge_bitmap
volume_gauge_refresh
update_config
end
end
#--------------------------------------------------------------------------
# ● 배경 스프라이트의 작성
#--------------------------------------------------------------------------
def create_volume_back_sprite
@back_sprite = Sprite.new
@back_sprite.bitmap = Bitmap.new(300, 110)
color = Color.new(0, 0, 0, 128)
@back_sprite.bitmap.fill_rect(@back_sprite.bitmap.rect, color)
wlh = 24
@back_sprite.bitmap.draw_text(4, 4, 128, 24, "음량 변경")
@back_sprite.bitmap.draw_text(28, 4 + wlh, 128, 24, "BGM/BGS")
@back_sprite.bitmap.draw_text(28, 6 + wlh * 2 , 128, 24, " ME / SE ")
@back_sprite.bitmap.draw_text(2, 4 + wlh , 24, 24, "→")
t = "※↑·↓·→·←그리고 변경, F5키로 종료."
@back_sprite.bitmap.font.size = 17
@back_sprite.bitmap.draw_text(4, 8 + wlh * 3 , 296, 24, t)
@back_sprite.bitmap.font.size = 20
end
#--------------------------------------------------------------------------
# ● 게이지용 비트 맵의 작성
#--------------------------------------------------------------------------
def create_volume_gauge_bitmap
@gauge_bitmap1 = Bitmap.new(12, 24)
@gauge_bitmap1.fill_rect(@gauge_bitmap1.rect, Color.new(255, 0, 0))
@gauge_bitmap1.fill_rect(0, 0, 2, 24, Color.new(255, 128, 128))
@gauge_bitmap1.fill_rect(0, 0, 23, 2, Color.new(255, 128, 128))
@gauge_bitmap1.fill_rect(10, 0, 2, 23, Color.new(128, 0, 0))
@gauge_bitmap1.fill_rect(0, 22, 12, 2, Color.new(128, 0, 0))
@gauge_bitmap2 = Bitmap.new(18, 24)
@gauge_bitmap2.fill_rect(@gauge_bitmap2.rect, Color.new(0, 0, 255))
@gauge_bitmap2.fill_rect(0, 0, 2, 24, Color.new(128, 128, 255))
@gauge_bitmap2.fill_rect(0, 0, 23, 2, Color.new(128, 128, 255))
@gauge_bitmap2.fill_rect(10, 0, 2, 23, Color.new(0, 0, 128))
@gauge_bitmap2.fill_rect(0, 22, 12, 2, Color.new(0, 0, 128))
end
#--------------------------------------------------------------------------
# ● 게이지 묘화
#--------------------------------------------------------------------------
def volume_gauge_refresh
@back_sprite.bitmap.clear_rect(156, 28, 200, 56)
@back_sprite.bitmap.fill_rect(156, 28, 200, 56, Color.new(0, 0, 0, 128))
src_bitmap = @gauge_bitmap1
src_rect = @gauge_bitmap1.rect
for i in 0...($game_system.volume_list[0] / 10)
@back_sprite.bitmap.blt(156 + i * 12, 28, src_bitmap, src_rect)
end
src_bitmap = @gauge_bitmap2
for i in 0...($game_system.volume_list[1] / 10)
@back_sprite.bitmap.blt(156 + i * 12, 54, src_bitmap, src_rect)
end
end
#--------------------------------------------------------------------------
# ● 콘피그후레임 갱신
#--------------------------------------------------------------------------
def update_config
index = 0
loop do
@back_sprite.update
Graphics.update
Input.update
Graphics.frame_count -= 1
if Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
Sound.play_decision
index += 1
index = 0 if index == 2
@back_sprite.bitmap.clear_rect(2, 28, 24, 56)
@back_sprite.bitmap.fill_rect(2, 28, 24, 56, Color.new(0, 0, 0, 128))
@back_sprite.bitmap.draw_text(2, 4 + 24 * (index + 1), 24, 24, "→")
elsif Input.repeat?(Input::RIGHT)
Sound.play_decision
@back_sprite.update
$game_system.volume_list[index] += 10
if $game_system.volume_list[index] >= 100
$game_system.volume_list[index] = 100
end
volume_gauge_refresh
RPG::BGM::last.play
elsif Input.repeat?(Input::LEFT)
Sound.play_decision
$game_system.volume_list[index] -= 10
if $game_system.volume_list[index] <= 0
$game_system.volume_list[index] = 0
end
volume_gauge_refresh
RPG::BGM::last.play
elsif Input.trigger?(Input::F5)
Sound.play_decision
@back_sprite.bitmap.dispose
@back_sprite.dispose
@gauge_bitmap1.dispose
@gauge_bitmap2.dispose
break
end
end
Graphics.wait(2)
end
end
module RPG
#==============================================================================
# ■ AudioFile
#==============================================================================
class AudioFile
alias dai_volume_initialize initialize unless $@
def initialize(name = "", volume = 100, pitch = 100)
dai_volume_initialize(name, volume, pitch)
@base_volume = @volume
end
#--------------------------------------------------------------------------
# ● 음량 변경
#--------------------------------------------------------------------------
def volume_change
@base_volume = @volume if @base_volume.nil?
@volume = (@base_volume * correction_value / 100)
end
#--------------------------------------------------------------------------
# ● 음량 보정치의 취득
#--------------------------------------------------------------------------
def correction_value
if self.is_a?(RPG::BGM) or self.is_a?(RPG::BGS)
return $game_system.volume_list[0]
elsif self.is_a?(RPG::ME) or self.is_a?(RPG::SE)
return $game_system.volume_list[1]
end
return 100
end
end
#==============================================================================
# ■ BGM
#==============================================================================
class BGM < AudioFile
alias dai_volume_play play unless $@
def play
volume_change
dai_volume_play
end
end
#==============================================================================
# ■ BGS
#==============================================================================
class BGS < AudioFile
alias dai_volume_play play unless $@
def play
volume_change
dai_volume_play
end
end
#==============================================================================
# ■ ME
#==============================================================================
class ME < AudioFile
alias dai_volume_play play unless $@
def play
volume_change
dai_volume_play
end
end
#==============================================================================
# ■ SE
#==============================================================================
class SE < AudioFile
alias dai_volume_play play unless $@
def play
volume_change
dai_volume_play
end
end
end
#==============================================================================
# ■ Game_System
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
alias dai_volume_initialize initialize
def initialize
dai_volume_initialize
@volume_list = [100, 100]
end
#--------------------------------------------------------------------------
# ● 음량 보정치의 취득
#--------------------------------------------------------------------------
def volume_list
@volume_list = [100, 100] if @volume_list.nil? # 세이브 파일 대책
return @volume_list
end
#--------------------------------------------------------------------------
# ● 음량 보정치
#--------------------------------------------------------------------------
def volume_list=(n)
@volume_list = n
end
end
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map
include Volume_Config
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
include Volume_Config
end
#==============================================================================
# ■ Scene_Menu
#==============================================================================
class Scene_Menu < Scene_Base
include Volume_Config
end
#==============================================================================
# ■ Scene_Item
#==============================================================================
class Scene_Item < Scene_Base
include Volume_Config
end
#==============================================================================
# ■ Scene_Skill
#==============================================================================
class Scene_Skill < Scene_Base
include Volume_Config
end
#==============================================================================
# ■ Scene_Equip
#==============================================================================
class Scene_Equip < Scene_Base
include Volume_Config
end
#==============================================================================
# ■ Scene_Status
#==============================================================================
class Scene_Status < Scene_Base
include Volume_Config
end
#==============================================================================
# ■ Scene_File
#==============================================================================
class Scene_File < Scene_Base
include Volume_Config
end
#==============================================================================
# ■ Scene_Shop
#==============================================================================
class Scene_Shop < Scene_Base
include Volume_Config
end
#==============================================================================
# ■ Scene_Name
#==============================================================================
class Scene_Name < Scene_Base
include Volume_Config
end
#==============================================================================
# ■ Scene_End
#==============================================================================
class Scene_End < Scene_Base
include Volume_Config
end
좋은정보 감사요~~