I have a little oddity I can't solve. I made myself an options menu with volume bars, and it all works as intended but for one small thing.
When pushing to the right, to make the volume higher, it goes very slowly. Tedious.
But when pushing to the left to lower it, it goes super fast in comparison. I would rather have them both go fast like that.
What could cause it? The code for both is the same.
The code:
When pushing to the right, to make the volume higher, it goes very slowly. Tedious.
But when pushing to the left to lower it, it goes super fast in comparison. I would rather have them both go fast like that.
What could cause it? The code for both is the same.
The code:
class Scene_Option < Scene_MenuBase
def start
super
create_option_window
end
def command_game_end
SceneManager.call(Scene_End)
end
def autorun_toggle
if $game_switches[1] == true
$game_switches[1] = false
elsif $game_switches[1] == false
$game_switches[1] = true
else $game_switches[1] = false
end
@option_window.activate
@option_window.refresh
end
def create_option_window
@option_window = Window_Option.new
@option_window.viewport = @viewport
@option_window.width = 300
@option_window.set_handler🙂game_end, method🙂command_game_end))
@option_window.set_handler🙂autorun, method🙂autorun_toggle))
@option_window.set_handler🙂cancel, method🙂return_scene))
@option_window.refresh
end
end
class Window_Option < Window_Command
def initialize
super(0, 0)
update_placement
end
def process_cursor_move
super
check_symbol
end
def refresh
super
music_bar
sfx_bar
autorun_on
autorun_off
end
def update_placement
pos_x = Graphics.width - 300
self.x = pos_x - (pos_x / 2)
self.y = (Graphics.height - height) / 2
end
def make_command_list
add_command("Music", :bgm)
add_command("SFX", :sfx)
add_command("Autorun", :autorun)
add_command("Quit", :game_end)
end
def check_symbol
if current_symbol == :bgm || current_symbol == :sfx
if Input.press?🙂LEFT) || Input.repeat?🙂LEFT)
lower_volume(current_symbol)
elsif Input.trigger?🙂RIGHT) || Input.repeat?🙂RIGHT)
raise_volume(current_symbol)
else return
end
else return
end
end
def lower_volume(type)
($game_variables[12] -= 1) if type == :bgm && $game_variables[12] > 0
($game_variables[13] -= 1) if type == :sfx && $game_variables[13] > 0
RPG::BGM::last.play
RPG::BGS::last.play
refresh
end
def raise_volume(type)
($game_variables[12] += 1) if type == :bgm && $game_variables[12] < 100
($game_variables[13] += 1) if type == :sfx && $game_variables[13] < 100
RPG::BGM::last.play
RPG::BGS::last.play
refresh
end
def music_bar
rect = item_rect(0)
rate = $game_variables[12]
value = sprintf("%d%", rate)
rate *= 0.01
draw_gauge(75, rect.y - 10, 100, rate, text_color(24), text_color(25))
draw_text(130, rect.y, 100, line_height, value, 2)
end
def sfx_bar
rect = item_rect(1)
rate = $game_variables[13]
value = sprintf("%d%", rate)
rate *= 0.01
draw_gauge(75, rect.y - 10, 100, rate, text_color(24), text_color(25))
draw_text(130, rect.y, 100, line_height, value, 2)
end
def autorun_on
reset_font_settings
rect = item_rect(2)
enabled = $game_switches[1]
contents.font.color.alpha = translucent_alpha unless enabled == true
draw_text(75, rect.y, 25, line_height, "On")
end
def autorun_off
reset_font_settings
rect = item_rect(2)
enabled = $game_switches[1]
contents.font.color.alpha = translucent_alpha unless enabled == false
draw_text(120, rect.y, 50, line_height, "Off")
end
end
#---------------------------------------------------------------------------
class RPG::BGM < RPG::AudioFile
def play(pos = 0)
if @name.empty?
Audio.bgm_stop
@@last = RPG::BGM.new
else
Audio.bgm_play('Audio/BGM/' + @Name, $game_variables[12], @pitch, pos)
@@last = self.clone
end
end
end
class RPG::BGS < RPG::AudioFile
def play(pos = 0)
if @name.empty?
Audio.bgs_stop
@@last = RPG::BGS.new
else
Audio.bgs_play('Audio/BGS/' + @Name, $game_variables[13], @pitch, pos)
@@last = self.clone
end
end
end
class RPG::SE < RPG::AudioFile
def play
unless @name.empty?
Audio.se_play('Audio/SE/' + @Name, $game_variables[13], @pitch)
end
end
end
def start
super
create_option_window
end
def command_game_end
SceneManager.call(Scene_End)
end
def autorun_toggle
if $game_switches[1] == true
$game_switches[1] = false
elsif $game_switches[1] == false
$game_switches[1] = true
else $game_switches[1] = false
end
@option_window.activate
@option_window.refresh
end
def create_option_window
@option_window = Window_Option.new
@option_window.viewport = @viewport
@option_window.width = 300
@option_window.set_handler🙂game_end, method🙂command_game_end))
@option_window.set_handler🙂autorun, method🙂autorun_toggle))
@option_window.set_handler🙂cancel, method🙂return_scene))
@option_window.refresh
end
end
class Window_Option < Window_Command
def initialize
super(0, 0)
update_placement
end
def process_cursor_move
super
check_symbol
end
def refresh
super
music_bar
sfx_bar
autorun_on
autorun_off
end
def update_placement
pos_x = Graphics.width - 300
self.x = pos_x - (pos_x / 2)
self.y = (Graphics.height - height) / 2
end
def make_command_list
add_command("Music", :bgm)
add_command("SFX", :sfx)
add_command("Autorun", :autorun)
add_command("Quit", :game_end)
end
def check_symbol
if current_symbol == :bgm || current_symbol == :sfx
if Input.press?🙂LEFT) || Input.repeat?🙂LEFT)
lower_volume(current_symbol)
elsif Input.trigger?🙂RIGHT) || Input.repeat?🙂RIGHT)
raise_volume(current_symbol)
else return
end
else return
end
end
def lower_volume(type)
($game_variables[12] -= 1) if type == :bgm && $game_variables[12] > 0
($game_variables[13] -= 1) if type == :sfx && $game_variables[13] > 0
RPG::BGM::last.play
RPG::BGS::last.play
refresh
end
def raise_volume(type)
($game_variables[12] += 1) if type == :bgm && $game_variables[12] < 100
($game_variables[13] += 1) if type == :sfx && $game_variables[13] < 100
RPG::BGM::last.play
RPG::BGS::last.play
refresh
end
def music_bar
rect = item_rect(0)
rate = $game_variables[12]
value = sprintf("%d%", rate)
rate *= 0.01
draw_gauge(75, rect.y - 10, 100, rate, text_color(24), text_color(25))
draw_text(130, rect.y, 100, line_height, value, 2)
end
def sfx_bar
rect = item_rect(1)
rate = $game_variables[13]
value = sprintf("%d%", rate)
rate *= 0.01
draw_gauge(75, rect.y - 10, 100, rate, text_color(24), text_color(25))
draw_text(130, rect.y, 100, line_height, value, 2)
end
def autorun_on
reset_font_settings
rect = item_rect(2)
enabled = $game_switches[1]
contents.font.color.alpha = translucent_alpha unless enabled == true
draw_text(75, rect.y, 25, line_height, "On")
end
def autorun_off
reset_font_settings
rect = item_rect(2)
enabled = $game_switches[1]
contents.font.color.alpha = translucent_alpha unless enabled == false
draw_text(120, rect.y, 50, line_height, "Off")
end
end
#---------------------------------------------------------------------------
class RPG::BGM < RPG::AudioFile
def play(pos = 0)
if @name.empty?
Audio.bgm_stop
@@last = RPG::BGM.new
else
Audio.bgm_play('Audio/BGM/' + @Name, $game_variables[12], @pitch, pos)
@@last = self.clone
end
end
end
class RPG::BGS < RPG::AudioFile
def play(pos = 0)
if @name.empty?
Audio.bgs_stop
@@last = RPG::BGS.new
else
Audio.bgs_play('Audio/BGS/' + @Name, $game_variables[13], @pitch, pos)
@@last = self.clone
end
end
end
class RPG::SE < RPG::AudioFile
def play
unless @name.empty?
Audio.se_play('Audio/SE/' + @Name, $game_variables[13], @pitch)
end
end
end