KMenuSound ACE
#1
KMenuSound ACE

by Kyonides Arkanthes


​Introduction

A board member once requested a new scriptlet that could help the game developer play a BGM on the main menu scene. It also lets you resume the previously played map BGM right where it was interrupted upon returning to the current map. This script does not alter the GUI at all so no screenshots should be provided ever! Laughing + Tongue sticking out

Code:
# * KMenuSound ACE
#   Scripter : Kyonides Arkanthes
#   2021-10-01

# This scriptlet will let you resume the BGM or BGS previously played on the
# current map right after exiting the menu scene. Besides the menu also features
# its very own BGM! Please feel free to set the values of KMenuSound module's
# Constants at will.

module KMenuSound
  BGM = "Theme2"
  VOLUME = 70
  PITCH = 100
  extend self
  attr_accessor :bgm_pos, :bgs_pos
  @bgm_pos = 0
  @bgs_pos = 0
end

class Game_Map
  def play_last_bgms
    @map.bgm.play(KMenuSound.bgm_pos) if @map.autoplay_bgm
    @map.bgs.play(KMenuSound.bgs_pos) if @map.autoplay_bgs
  end
end

class Scene_Menu
  include KMenuSound
  alias :kyon_menusnd_scn_menu_start :start
  def start
    kyon_menusnd_scn_menu_start
    bgm = RPG::BGM.new(BGM, VOLUME, PITCH)
    bgm.play
  end
end

class Scene_Map
  alias :kyon_menusnd_scn_map_start2 :post_start
  alias :kyon_menusnd_scn_map_call_menu :call_menu
  def post_start
    kyon_menusnd_scn_map_start2
    $game_map.play_last_bgms
  end

  def call_menu
    KMenuSound.bgm_pos = RPG::BGM.last.pos
    KMenuSound.bgs_pos = RPG::BGS.last.pos
    kyon_menusnd_scn_map_call_menu
  end
end


Terms & Conditions

Feel free to use it anywhere.
Mention me in your game credits! Laughing + Tongue sticking out
[End of Conditions]
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }




Users browsing this thread: 2 Guest(s)