Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 17, 2005, 4:02:36 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/weaponSystem: connecting sounds to the weapon works fine now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/weaponSystem/src/lib/sound/sound_engine.cc

    r4880 r4883  
    9191 *  creates a SoundSource at position sourceNode with the SoundBuffer buffer
    9292*/
    93 SoundSource::SoundSource(SoundBuffer* buffer, PNode* sourceNode)
     93SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer)
    9494{
    9595  this->setClassID(CL_SOUND_SOURCE, "SoundSource");
     
    106106  if ((result = alGetError()) != AL_NO_ERROR)
    107107    SoundEngine::PrintALErrorString(result);
    108   alSourcei (this->sourceID, AL_BUFFER,   this->buffer->getID());
     108  if (this->buffer != NULL)
     109    alSourcei (this->sourceID, AL_BUFFER,   this->buffer->getID());
    109110  alSourcef (this->sourceID, AL_PITCH,    1.0      );
    110111  alSourcef (this->sourceID, AL_GAIN,     1.0      );
     
    127128{
    128129  alSourcePlay(this->sourceID);
     130}
     131
     132/**
     133 * Plays back buffer on this Source
     134 * @param buffer the buffer to play back on this Source
     135 */
     136void SoundSource::play(const SoundBuffer* buffer)
     137{
     138  alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     139  alSourcePlay(this->sourceID);
     140//  printf("playing sound\n");
    129141}
    130142
     
    229241SoundSource* SoundEngine::createSource(const char* fileName, PNode* sourceNode)
    230242{
    231   return new SoundSource((SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL), sourceNode);
     243  return new SoundSource(sourceNode, (SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL));
    232244}
    233245
Note: See TracChangeset for help on using the changeset viewer.