Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

SE insert

Bobb

Member

hello im using rpgmaker XP.
and was wondering how i would go about adding a sound effect for when you level up?
 
This is how I would do it. Keep in mind I use an alias instead of overwritting the origional method (an alias is used to add code before/after an old method is called)

Code:
class Game_Actor < Game_Battler

  alias_method :seplaywhenlevel_gmactor_chgexp, :exp=

  def exp=(exp)

    # Store old level...

    old_level = self.level

    # Call old method...

    seplaywhenlevel_gmactor_chgexp(exp)

    # If now level is less than previous

    if self.level < old_level

      # Play level down sound

      Audio.se_play("Audio/SE/058-Wrong02", 100, 100)

    # Else if now level is more than previous

    elsif self.level > old_level

      # Play level up sound

      Audio.se_play("Audio/SE/056-Right02", 100, 100)

    end

  end

end
 

Bobb

Member

i used Audio.se_play("Audio/SE/056-Right02", 100, 100)
and put it in Window_BattleStatus
after self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
this seems to work it was that i didnt know how to reference a sound
thanks Kain Nobel
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top