Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
SoundNode.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_SoundNode_h_ 00003 #define INCLUDED_SoundNode_h_ 00004 00005 #include "Behaviors/StateNode.h" 00006 #include "Events/EventRouter.h" 00007 #include "SoundPlay/SoundManager.h" 00008 00009 //! A simple StateNode that plays a sound upon startup and throws a status event on completion 00010 class SoundNode : public StateNode { 00011 protected: 00012 std::string filename; 00013 SoundManager::Play_ID curplay_id; 00014 00015 public: 00016 //! constructor 00017 SoundNode(std::string nodename="SoundNode", std::string soundfilename="") : 00018 StateNode(nodename), filename(soundfilename), curplay_id(SoundManager::invalid_Play_ID) {} 00019 00020 //! activate the node 00021 virtual void DoStart() { 00022 curplay_id = sndman->PlayFile(filename); 00023 erouter->addListener(this,EventBase::audioEGID,curplay_id,EventBase::deactivateETID); 00024 StateNode::DoStart(); // don't activate transitions until our listener has been added 00025 } 00026 00027 //! deactivate the node 00028 virtual void DoStop() { 00029 erouter->removeListener(this); 00030 StateNode::DoStop(); 00031 } 00032 00033 //! receive audioEGID status event and throw stateMachineEGID status event 00034 virtual void processEvent(const EventBase&) { 00035 erouter->postEvent(EventBase::stateMachineEGID,(unsigned int)this,EventBase::statusETID,0); 00036 } 00037 00038 //! interrupts playing of the current sound 00039 void StopPlay() { 00040 sndman->StopPlay(curplay_id); 00041 curplay_id = SoundManager::invalid_Play_ID; 00042 } 00043 00044 //! returns the name of the sound file associated with this node 00045 std::string getFileName() { return filename; } 00046 00047 //! sets the name of the sound file associated with this node 00048 void setFileName(std::string &soundfilename) { filename = soundfilename; } 00049 00050 }; 00051 00052 /*! @file 00053 * @brief Defines SoundNode, a simple StateNode that plays a sound and throws a status event upon completion 00054 * @author dst (Creator) 00055 * 00056 * $Author: dst $ 00057 * $Name: tekkotsu-2_2 $ 00058 * $Revision: 1.5 $ 00059 * $State: Exp $ 00060 * $Date: 2004/10/08 00:08:47 $ 00061 */ 00062 00063 #endif |
Tekkotsu v2.2 |
Generated Tue Oct 19 14:19:16 2004 by Doxygen 1.3.9.1 |