X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftrigger%2Fswitch.cpp;h=23f5754f8fa741881aeb7c362380a183f673c1fd;hb=b221f746629259e96f248a336fe4f4e37e3385e0;hp=e11a5b68b3d2ed169531a7792face3dcf7ce8c29;hpb=c9e5a8a4f0627f7e2a0406e8a46c26aed0de77a7;p=supertux.git diff --git a/src/trigger/switch.cpp b/src/trigger/switch.cpp index e11a5b68b..23f5754f8 100644 --- a/src/trigger/switch.cpp +++ b/src/trigger/switch.cpp @@ -25,6 +25,11 @@ #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" #include "sector.hpp" +#include "audio/sound_manager.hpp" + +namespace { + const std::string SWITCH_SOUND = "sounds/switch.ogg"; +} Switch::Switch(const lisp::Lisp& reader) : state(OFF) @@ -36,6 +41,7 @@ Switch::Switch(const lisp::Lisp& reader) bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); if (!reader.get("script", script)) throw std::runtime_error("no script set"); + sound_manager->preload( SWITCH_SOUND ); } Switch::~Switch() @@ -98,6 +104,7 @@ Switch::event(Player& , EventType type) switch (state) { case OFF: sprite->set_action("turnon", 1); + sound_manager->play( SWITCH_SOUND ); state = TURN_ON; break; case TURN_ON: @@ -111,4 +118,3 @@ Switch::event(Player& , EventType type) } IMPLEMENT_FACTORY(Switch, "switch"); -