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.

RMXP Sound When Level?

xctive

Member

What I would like to happen is just to play a sound effect every time the player levels. How would I go about this anyone know?
 

xctive

Member

Im using the code from that link
Code:
class Window_BattleStatus

  #--------------------------------------------------------------------------

  # * Set Level Up Flag

  #     actor_index : actor index

  #--------------------------------------------------------------------------

  def level_up(actor_index)

    @level_up_flags[actor_index] = true

    $game_system.se_play("Action01")

  end

 end

and when I level I get an error that says there is no method for my sound title its at line 129 under game_system this is the area.
Code:
#--------------------------------------------------------------------------

  # * Play Sound Effect

  #     se : sound effect to be played

  #--------------------------------------------------------------------------

  def se_play(se)

    if se != nil and se.name != ""

      Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)

    end

  end
 
Yeh, I pooched it when I posted that. Look at the bottom post!
se_play expects an AudioFile object, not just the name (string).

I really should have written it like this, to avoid conflicts with other systems that modify level_up:

Code:
class Window_BattleStatus

  #--------------------------------------------------------------------------

  # * Set Level Up Flag

  #     actor_index : actor index

  #--------------------------------------------------------------------------

 

  alias se_level_up level_up

 

  def level_up(actor_index)

    se_level_up(actor_index)

    sound = RPG::AudioFile.new("LevelUp")

    $game_system.se_play(sound)

  end

end
 

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