Sound Effect when Cancelling a menu

Hello,

I'm working in RPG Maker VX Ace and I'm new to scripting. Right now I'm putting a custom menu together, so far everything is working properly as far as transitioning back and forth between windows, however I'd like to be able to add my own sound effect when cancelling the sub menu and returning to the main menu. How would I go about doing that? I assume I'd add it into the same method used to return to the previous scene? I'm inheriting from Scene_MenuBase

  def update

    super()

    return_scene if Input.trigger?🙂B ) #Added a space as the forum was making a smily face lol

  end

 

 

 

 

Thank you for your time and consideration,

 

~Madix
Strictly speaking, this doesn't need scripting at all.  On the 'Terms' tab of the data base you can select a different sound effect for the 'cancel' function (which I assume is what you are referring to).  Simply import the SE of your choice and use that check box to select it.
Why do you need a Input.trigger in the first place I might ask? 🙂

You would usually assign set_handlers to the window that adds the methods necessary to press enter and cancel.

Example:

class Scene_Menu < Scene_MenuBase def start super create_command_window end def create_command_window @command_window = WindowCommand.new @command_window.set_handler🙂cancel, method🙂command_cancel)) end def command_cancel Sound.play_cancel # Do other stuff here... endendAltought, as ksjp17 said you don't need a script for that since methods already exists for decision and cancel sounds.
Sorry, to be more clear it's not playing any sound currently. It simply returns to the previous window. The sound in the database in the System Tab is currently set to the default Cancel2 sound effect.
 
I've customized the default menu windows such as items, equipment, skills etc. and in those scripts I was able to stick with with the below way to return to the previous window;

   def create_category_window    @category_window = Window_ItemCategory.new    @category_window.viewport = @viewport    @category_window.help_window = @help_window    @category_window.y = @help_window.height    @category_window.set_handler🙂ok,     method🙂on_category_ok))    @category_window.set_handler🙂cancel, method🙂return_scene))    @category_window.opacity = 0    @help_window.opacity = 0  endThe above plays the default cancel sound effect. However I've created a whole new window called Scene_Options which I'm going to use to control BGM and SE volume among a few other things. I tried to set it up the same way as above but I'm sure I'm doing it wrong as I'm new at this. However it wouldn't return to the previous scene, that's why I went with the trigger. Below is the script I tried to use with the handler, if you would be able to so kindly point out what I'm doing wrong that would be awesome =D

Code:
 # Creating Custom Scene class Scene_Options < Scene_MenuBase    #--------------------------------------------------------------------------  # * Start Processing  #--------------------------------------------------------------------------  def start    super    @option_window = Window_Options.new    @option_window.set_handler(:cancel,   method(:return_scene))  end     #--------------------------------------------------------------------------  # * Create Background  #--------------------------------------------------------------------------      def start    super()    @background_sprite            = Sprite.new    @background_sprite.bitmap     = Cache.system("Menu_Main")  end   #--------------------------------------------------------------------------  # * Free Background  #--------------------------------------------------------------------------     def dispose_background    @background_sprite.bitmap.dispose    @background_sprite.dispose  end     end
I'm using a number of scripts that add menu options and a few of them do not make the default cancelling noise. Is there any way to ensure that all menu scenes use the same noise globally.... By adding a little script? Or is this unsolvable in a global way...
Sounds like you haven't quite followed the example of the window you based it on. If the default scenes give you a SE when you cancel, you should find out where that happens, and make sure yours does the same thing.
You have two methods called start.
yep, that'd do it. The second method overwrites the first, which means your cancel handler is never set.


I think the second start is meant to be called create_background, and I'd check to see if the scene you're basing it on begins the create_background method with a call to super.

Original thread: https://forums.rpgmakerweb.com/threads/sound-effect-when-cancelling-a-menu.19681/