MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / ResSound

Class ResSound

LuaSTGPlus/ResourceMgr.h:334–380  ·  view source on GitHub ↗

@brief 音效

Source from the content-addressed store, hash-verified

332
333 /// @brief 音效
334 class ResSound :
335 public Resource
336 {
337 private:
338 fcyRefPointer<f2dSoundBuffer> m_pBuffer;
339 public:
340 void Play(float vol, float pan)
341 {
342 m_pBuffer->Stop();
343
344 float nv = VolumeFix(vol);
345 if (m_pBuffer->GetVolume() != nv)
346 m_pBuffer->SetVolume(nv);
347 if (m_pBuffer->GetPan() != pan)
348 m_pBuffer->SetPan(pan);
349
350 m_pBuffer->Play();
351 }
352
353 void Resume()
354 {
355 m_pBuffer->Play();
356 }
357
358 void Pause()
359 {
360 m_pBuffer->Pause();
361 }
362
363 void Stop()
364 {
365 m_pBuffer->Stop();
366 }
367
368 bool IsPlaying()
369 {
370 return m_pBuffer->IsPlaying();
371 }
372
373 bool IsStopped()
374 {
375 return !IsPlaying() && m_pBuffer->GetTime() == 0.;
376 }
377 public:
378 ResSound(const char* name, fcyRefPointer<f2dSoundBuffer> buffer)
379 : Resource(ResourceType::SoundEffect, name), m_pBuffer(buffer) {}
380 };
381
382 /// @brief 背景音乐
383 class ResMusic :

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected