Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
Transition.ccGo to the documentation of this file.00001 #include "Transition.h" 00002 #include "StateNode.h" 00003 #include "Wireless/Wireless.h" 00004 #include "SoundPlay/SoundManager.h" 00005 00006 /*! @deprecated, use the version of the constructor where you can pass a name */ 00007 Transition::Transition() : BehaviorBase("Transition"), srcs(), dsts(), sound() {} 00008 00009 /*! @deprecated, use the version of the constructor where you can pass a name */ 00010 Transition::Transition(StateNode* destination) 00011 : BehaviorBase("Transition"), srcs(), dsts(), sound() 00012 { 00013 addDestination(destination); 00014 } 00015 00016 00017 /*! @deprecated: use #fire() instead (just a better name) */ 00018 void Transition::activate() { 00019 serr->printf("Transition::activate() is deprecated. Use Transition::fire() instead.\n"); 00020 fire(); 00021 } 00022 00023 void Transition::fire() { 00024 //serr->printf("%s fire() - enter %d\n",getName().c_str(),get_time()); 00025 00026 AddReference(); //just in case a side effect of this transition is to dereference the transition, we don't want to be deleted while still transitioning 00027 00028 if(sound.size()!=0) 00029 sndman->PlayFile(sound); 00030 00031 for(unsigned int i=0; i<srcs.size(); i++) 00032 if(srcs[i]->isActive()) //It's usually a bad idea to call DoStop/DoStart when it's already stopped/started... 00033 srcs[i]->DoStop(); 00034 for(unsigned int i=0; i<dsts.size(); i++) 00035 if(!dsts[i]->isActive()) 00036 dsts[i]->DoStart(); 00037 00038 //serr->printf("%s fire() - leave %d\n",getName().c_str(),get_time()); 00039 RemoveReference(); 00040 } 00041 00042 std::string Transition::getName() const { 00043 if(instanceName != className) { 00044 return instanceName; 00045 } else { 00046 std::string ans; 00047 ans+='{'; 00048 for(unsigned int i=0; i<srcs.size(); i++) 00049 ans+=srcs[i]->getName()+(i<srcs.size()-1?',':'}'); 00050 ans+="--"+instanceName+"-->"; 00051 ans+='{'; 00052 for(unsigned int i=0; i<dsts.size(); i++) 00053 ans+=dsts[i]->getName()+(i<srcs.size()-1?',':'}'); 00054 return ans; 00055 } 00056 } 00057 00058 /*! @file 00059 * @brief Implements Transition, represents a transition between StateNodes. 00060 * @author ejt (Creator) 00061 * 00062 * $Author: ejt $ 00063 * $Name: tekkotsu-2_2_1 $ 00064 * $Revision: 1.11 $ 00065 * $State: Exp $ 00066 * $Date: 2004/11/11 20:34:59 $ 00067 */ 00068 |
Tekkotsu v2.2.1 |
Generated Tue Nov 23 16:36:40 2004 by Doxygen 1.3.9.1 |