Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6227


Ignore:
Timestamp:
Dec 3, 2009, 5:14:49 PM (14 years ago)
Author:
youngk
Message:

Inserted a firing sound into HsW01. BUG Sound plays only once on first fire.

Location:
code/branches/presentation2/src/modules/weapons/weaponmodes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc

    r6150 r6227  
    4242#include "worldentities/pawns/Pawn.h"
    4343
     44#include "sound/WorldSound.h"
     45
    4446namespace orxonox
    4547{
     
    5052        RegisterObject(HsW01);
    5153
    52         this->reloadTime_ = 0.25;
     54        this->reloadTime_ = 0.5;
    5355        this->damage_ = 15;
    5456        this->speed_ = 2500;
     
    5860        this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&HsW01::shot, this)));
    5961        this->delayTimer_.stopTimer();
     62
     63        this->defSndWpnFire_ = new WorldSound(this);
     64        this->defSndWpnFire_->setLooping(false);
     65        this->setDefaultSound("sounds/Weapon_Laser_shrt.ogg");
     66    }
     67
     68    HsW01::~HsW01()
     69    {
     70        if(this->isInitialized())
     71        {
     72            delete this->defSndWpnFire_;
     73        }
    6074    }
    6175
     
    92106    void HsW01::fire()
    93107    {
     108        this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->attach(this->defSndWpnFire_);
     109        this->defSndWpnFire_->play();
     110
    94111        this->delayTimer_.startTimer();
     112
     113        //this->defSndWpnFire_->stop();
    95114    }
    96115
     
    123142        HsW01::muendungsfeuer();
    124143    }
     144
     145    void HsW01::setDefaultSound(const std::string& soundPath)
     146    {
     147        this->defSndWpnFire_->setSource(soundPath);
     148    }
     149
     150    const std::string& HsW01::getDefaultSound()
     151    {
     152        return this->defSndWpnFire_->getSource();
     153    }
    125154}
  • code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.h

    r5929 r6227  
    4141        public:
    4242            HsW01(BaseObject* creator);
    43             virtual ~HsW01() {}
     43            virtual ~HsW01();
    4444
    4545            virtual void fire();
    4646            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     47
     48            void setDefaultSound(const std::string& soundPath);
     49            const std::string& getDefaultSound();
    4750
    4851        private:
     
    5861            float delay_;
    5962            Timer delayTimer_;
     63
     64            WorldSound* defSndWpnFire_;
    6065    };
    6166}
Note: See TracChangeset for help on using the changeset viewer.