X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fbadguy%2Fwillowisp.cpp;h=6480c1675f9e3715c63393aac95486296534cb30;hb=7c2f8e23f9accd00bd9ee2319da8ab8aa341c7cf;hp=69de9166d35d7478f8b581f5bf3390b0ef0f2a1c;hpb=f135ee3fa4a3e61f09da32c1b8e2145b655b247a;p=supertux.git diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index 69de9166d..6480c1675 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -26,14 +26,16 @@ static const float FLYSPEED = 64; /**< speed in px per second */ static const float TRACK_RANGE = 384; /**< at what distance to start tracking the player */ static const float VANISH_RANGE = 512; /**< at what distance to stop tracking and vanish */ +static const std::string SOUNDFILE = "sounds/willowisp.wav"; WillOWisp::WillOWisp(const lisp::Lisp& reader) - : BadGuy(reader, "images/creatures/willowisp/willowisp.sprite", LAYER_FLOATINGOBJECTS), mystate(STATE_IDLE), target_sector("main"), target_spawnpoint("main"), soundSource(sound_manager, "sounds/willowisp.wav") + : BadGuy(reader, "images/creatures/willowisp/willowisp.sprite", LAYER_FLOATINGOBJECTS), mystate(STATE_IDLE), target_sector("main"), target_spawnpoint("main") { reader.get("sector", target_sector); reader.get("spawnpoint", target_spawnpoint); countMe = false; + sound_manager->preload(SOUNDFILE); } void @@ -85,7 +87,7 @@ WillOWisp::active_update(float elapsed_time) mystate = STATE_VANISHING; sprite->set_action("vanishing", 1); } - soundSource.set_position(get_pos()); + sound_source->set_position(get_pos()); } if (mystate == STATE_WARPING) { @@ -107,18 +109,18 @@ WillOWisp::activate() { sprite->set_action("idle"); - soundSource.set_position(get_pos()); - soundSource.set_looping(true); - soundSource.set_gain(2.0); - soundSource.set_reference_distance(32); - soundSource.play(); + sound_source.reset(sound_manager->create_sound_source(SOUNDFILE)); + sound_source->set_position(get_pos()); + sound_source->set_looping(true); + sound_source->set_gain(2.0); + sound_source->set_reference_distance(32); + sound_source->play(); } void WillOWisp::deactivate() { - soundSource.stop(); - soundSource.release(); + sound_source.reset(NULL); switch (mystate) { case STATE_IDLE: