Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 4, 2009, 3:40:08 PM (15 years ago)
Author:
erwin
Message:

ambient sound loading for levels

Location:
code/branches/sound/src/orxonox/objects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sound/src/orxonox/objects/Level.cc

    r2826 r2950  
    7777        XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode);
    7878        XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
     79       
     80        XMLPortParamLoadOnly(Level, "ambientsound", loadAmbientSound, xmlelement, mode);
    7981
    8082        XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
     
    148150    }
    149151
     152    void Level::loadAmbientSound(const std::string& filename)
     153    {
     154        if(filename == "") return;
     155        else
     156        {
     157            if(this->ambientsound_ == NULL)
     158            {
     159                this->ambientsound_ = new SoundBase();
     160                this->sndmgr_.addSound(this->ambientsound_);
     161            }
     162
     163            this->ambientsound_->loadFile(filename);
     164            this->ambientsound_->play();
     165        }
     166    }
     167
    150168    void Level::playerEntered(PlayerInfo* player)
    151169    {
  • code/branches/sound/src/orxonox/objects/Level.h

    r2826 r2950  
    3333
    3434#include "network/synchronisable/Synchronisable.h"
     35#include "sound/SoundBase.h"
     36#include "sound/SoundManager.h"
    3537#include "core/BaseObject.h"
    3638
     
    5052            inline const std::string& getDescription() const
    5153                { return this->description_; }
     54
     55            void loadAmbientSound(const std::string& filename);
    5256
    5357            void playerEntered(PlayerInfo* player);
     
    6973            XMLFile*               xmlfile_;
    7074            std::list<BaseObject*> objects_;
     75            SoundManager           sndmgr_;
     76            SoundBase*             ambientsound_;
    7177    };
    7278}
Note: See TracChangeset for help on using the changeset viewer.