本文整理汇总了C++中sgd::AudioManager类的典型用法代码示例。如果您正苦于以下问题:C++ AudioManager类的具体用法?C++ AudioManager怎么用?C++ AudioManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AudioManager类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Enter
/*virtual*/ void IntroState::Enter(void)
{
// Set background color
SGD::GraphicsManager::GetInstance()->SetClearColor({ 0, 0, 0 }); // black
//starting_y = Game::GetInstance()->GetScreenHeight() + 20.0F;// * 15.0F;// + 170.0F;
// Load assets
SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance();
SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
AnimationManager* pAnimationManager = AnimationManager::GetInstance();
//pAnimationManager->Load("resource/config/animations/Zombie_Animation_New.xml", "zombie");
//animation.m_strCurrAnimation = "zombie";
m_hBackgroundImage = pGraphics->LoadTexture("resource/graphics/MenuImages/emergencybroadcast.png");
m_hEmergency = pAudio->LoadAudio("resource/audio/zombieemergency.wav");
IntroTimer.AddTime(60);
ScreenTimer.AddTime(.1f);
pAudio->PlayAudio(m_hEmergency, false);
//m_hBackgroundImage = pGraphics->LoadTexture("resource/graphics/youLose.png");
//m_hBackgroundMusic = pAudio->LoadAudio("resource/audio/JNB_Credits_PinballGroove.xwm");
//pAudio->PlayAudio(m_hBackgroundMusic);
}
示例2: if
// Enter
/*virtual*/ void IntroState::Enter(void)
{
// Set background color
SGD::GraphicsManager::GetInstance()->SetClearColor({ 0, 0, 0 }); // black
//starting_y = Game::GetInstance()->GetScreenHeight() + 20.0F;// * 15.0F;// + 170.0F;
// Load assets
SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance();
SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
AnimationManager* pAnimationManager = AnimationManager::GetInstance();
//pAnimationManager->Load("resource/config/animations/Zombie_Animation_New.xml", "zombie");
//animation.m_strCurrAnimation = "zombie";
pAudio->SetVoiceVolume(Game::GetInstance()->m_hMainVoice, 35);
m_hBackgroundImage = pGraphics->LoadTexture("resource/graphics/MenuImages/emergencybroadcast.png");
m_hinstruct = SGD::GraphicsManager::GetInstance()->LoadTexture("resource/graphics/MenuImages/ArcadeControlsIcons.png");
m_hEmergency = pAudio->LoadAudio("resource/audio/zombieemergency.wav");
if (IntroTimer.GetTime() < 45.0f)
{
float newTime = 45.0f - IntroTimer.GetTime();
IntroTimer.AddTime(newTime);
}
else if (IntroTimer.GetTime() <= 0.0f)
IntroTimer.AddTime(45.0f);
if (ScreenTimer.GetTime() < .1f)
{
float newTime = .1f - ScreenTimer.GetTime();
ScreenTimer.AddTime(newTime);
}
else if (ScreenTimer.GetTime() <= 0.0f)
ScreenTimer.AddTime(.1f);
transBack = 255;
transTextFirst = 0;
transText = 0;
//IntroTimer.AddTime(45.0f - IntroTimer.GetTime());
//ScreenTimer.AddTime(.1f - ScreenTimer.GetTime());
pAudio->PlayAudio(m_hEmergency, false);
//m_hBackgroundImage = pGraphics->LoadTexture("resource/graphics/youLose.png");
//m_hBackgroundMusic = pAudio->LoadAudio("resource/audio/JNB_Credits_PinballGroove.xwm");
//pAudio->PlayAudio(m_hBackgroundMusic);
}
示例3: SpawnTurret
void Player::SpawnTurret(void)
{
SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
Game* pGame = Game::GetInstance();
if (profile.numTurrets == 0 || GoodTurretPosition() == false)
{
if (pAudio->IsAudioPlaying(pGame->turret_bad) == false)
pAudio->PlayAudio(pGame->turret_bad, false);
return;
}
if (pAudio->IsAudioPlaying(pGame->turret_good) == false)
pAudio->PlayAudio(pGame->turret_good, false);
// create turret message
CreateTurretMessage* pMsg = new CreateTurretMessage(this);
pMsg->QueueMessage();
pMsg = nullptr;
profile.numTurrets--;
}
示例4: Unload
void TowerFlyweight::Unload()
{
// Unload sounds
SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
pAudio->UnloadAudio(m_hSellSound);
pAudio->UnloadAudio(m_hInvalidSound);
pAudio->UnloadAudio(m_hMachineGunShotSound);
pAudio->UnloadAudio(m_hMapleSyrupShotSound);
pAudio->UnloadAudio(m_hHockeyStickSlashSound);
}
示例5: Fire
void FlameThrower::Fire(float dt)
{
SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
Game* pGame = Game::GetInstance();
if (currAmmo > 0 && reloadTimer.GetTime() == 0)
{
//create bullet message
if (recoilTimer.GetTime() == 0 && pAudio->IsAudioPlaying(pGame->reload_finish) == false)
{
CreateFlameBullet* pMsg = new CreateFlameBullet(this);
pMsg->QueueMessage();
pMsg = nullptr;
if (pAudio->IsAudioPlaying(*fire_sound) == false)
pAudio->PlayAudio(*fire_sound, false);
recoilTimer.AddTime(recoilTime);
currAmmo--;
if (currAmmo == 0)
{
reloadTimer.AddTime(reloadTime);
reloading = true;
}
}
}
else
{
if (pAudio->IsAudioPlaying(pGame->out_of_ammo) == false && pAudio->IsAudioPlaying(*fire_sound) == false
&& pAudio->IsAudioPlaying(pGame->reload_begin) == false
&& pAudio->IsAudioPlaying(pGame->reload_finish) == false)
pAudio->PlayAudio(pGame->out_of_ammo, false);
}
}
示例6: CheckDamage
void Player::CheckDamage(void)
{
SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
Game* pGame = Game::GetInstance();
// dead, !hurt
if (profile.health <= 0.0f)
{
profile.health = 0.0f;
if (m_hHurt != nullptr && pAudio->IsAudioPlaying(*m_hHurt) == true)
pAudio->StopAudio(*m_hHurt);
if (pAudio->IsAudioPlaying(*m_hDeath) == false)
voice = pAudio->PlayAudio(*m_hDeath, false);
pAudio->SetVoiceVolume(voice);
m_bIsAlive = false;
SetVelocity({ 0, 0 });
}
// hurt, !dead
else
{
int sound = rand() % 3;
switch (sound)
{
case 0:
m_hHurt = &pGame->playerHurt1;
break;
case 1:
m_hHurt = &pGame->playerHurt2;
break;
case 2:
m_hHurt = &pGame->playerHurt3;
break;
default:
break;
}
if (pAudio->IsAudioPlaying(pGame->playerHurt1) == false &&
pAudio->IsAudioPlaying(pGame->playerHurt2) == false &&
pAudio->IsAudioPlaying(pGame->playerHurt3) == false)
voice = pAudio->PlayAudio(*m_hHurt, false);
pAudio->SetVoiceVolume(voice);
m_hHurt = nullptr;
}
}
示例7:
// Exit
/*virtual*/ void IntroState::Exit(void)
{
SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance();
SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance();
// Unload assets
pGraphics->UnloadTexture(m_hBackgroundImage);
pGraphics->UnloadTexture(m_hinstruct);
//pAudio->UnloadAudio(m_hBackgroundMusic);
pAudio->UnloadAudio(m_hEmergency);
pAudio->SetVoiceVolume(Game::GetInstance()->m_hMainVoice, 100);
}
示例8: Load
//.........这里部分代码省略.........
// Damage Upgrade Values
TiXmlElement* hockeyStickDamage = hockeyStick->FirstChildElement("damage_upgrade");
// Tier 1
TiXmlElement* hockeyStickDamageOne = hockeyStickDamage->FirstChildElement("tier_one");
hockeyStickDamageOne->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickDamageUpgradeCost[0]);
hockeyStickDamageOne->FirstChildElement("damage")->Attribute("value", &temp);
m_fHockeyStickDamage[1] = (float)temp;
// Tier 2
TiXmlElement* hockeyStickDamageTwo = hockeyStickDamage->FirstChildElement("tier_two");
hockeyStickDamageTwo->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickDamageUpgradeCost[1]);
hockeyStickDamageTwo->FirstChildElement("damage")->Attribute("value", &temp);
m_fHockeyStickDamage[2] = (float)temp;
// Tier 3
TiXmlElement* hockeyStickDamageThree = hockeyStickDamage->FirstChildElement("tier_three");
hockeyStickDamageThree->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickDamageUpgradeCost[2]);
hockeyStickDamageThree->FirstChildElement("damage")->Attribute("value", &temp);
m_fHockeyStickDamage[3] = (float)temp;
// Spin Rate Upgrade Values
TiXmlElement* hockeyStickSpinRate = hockeyStick->FirstChildElement("spin_rate_upgrade");
// Tier 1
TiXmlElement* hockeyStickSpinRateOne = hockeyStickSpinRate->FirstChildElement("tier_one");
hockeyStickSpinRateOne->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickSpinRateUpgradeCost[0]);
hockeyStickSpinRateOne->FirstChildElement("spin_rate")->Attribute("value", &temp);
m_fHockeyStickSpinRate[1] = (float)temp;
// Tier 2
TiXmlElement* hockeyStickSpinRateTwo = hockeyStickSpinRate->FirstChildElement("tier_two");
hockeyStickSpinRateTwo->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickSpinRateUpgradeCost[1]);
hockeyStickSpinRateTwo->FirstChildElement("spin_rate")->Attribute("value", &temp);
m_fHockeyStickSpinRate[2] = (float)temp;
// Tier 3
TiXmlElement* hockeyStickSpinRateThree = hockeyStickSpinRate->FirstChildElement("tier_three");
hockeyStickSpinRateThree->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickSpinRateUpgradeCost[2]);
hockeyStickSpinRateThree->FirstChildElement("spin_rate")->Attribute("value", &temp);
m_fHockeyStickSpinRate[3] = (float)temp;
#pragma endregion
#pragma region Laser Tower
// Laser Tower
TiXmlElement* laser = pRoot->FirstChildElement("laser");
// Starting Values
laser->FirstChildElement("damage")->Attribute("value", &m_nLaserDamage[0]);
laser->FirstChildElement("range")->Attribute("value", &m_nLaserRange[0]);
// Damage Upgrade Values
TiXmlElement* laserDamage = laser->FirstChildElement("damage_upgrade");
// Tier 1
TiXmlElement* laserDamageOne = laserDamage->FirstChildElement("tier_one");
laserDamageOne->FirstChildElement("cost")->Attribute("value", &m_nLaserDamageUpgradeCost[0]);
laserDamageOne->FirstChildElement("damage")->Attribute("value", &m_nLaserDamage[1]);
// Tier 2
TiXmlElement* laserDamageTwo = laserDamage->FirstChildElement("tier_two");
laserDamageTwo->FirstChildElement("cost")->Attribute("value", &m_nLaserDamageUpgradeCost[1]);
laserDamageTwo->FirstChildElement("damage")->Attribute("value", &m_nLaserDamage[2]);
// Tier 3
TiXmlElement* laserDamageThree = laserDamage->FirstChildElement("tier_three");
laserDamageThree->FirstChildElement("cost")->Attribute("value", &m_nLaserDamageUpgradeCost[2]);
laserDamageThree->FirstChildElement("damage")->Attribute("value", &m_nLaserDamage[3]);
// Range Upgrade Values
TiXmlElement* laserRange = laser->FirstChildElement("range_upgrade");
// Tier 1
TiXmlElement* laserRangeOne = laserRange->FirstChildElement("tier_one");
laserRangeOne->FirstChildElement("cost")->Attribute("value", &m_nLaserRangeUpgradeCost[0]);
laserRangeOne->FirstChildElement("range")->Attribute("value", &m_nLaserRange[1]);
// Tier 2
TiXmlElement* laserRangeTwo = laserRange->FirstChildElement("tier_two");
laserRangeTwo->FirstChildElement("cost")->Attribute("value", &m_nLaserRangeUpgradeCost[1]);
laserRangeTwo->FirstChildElement("range")->Attribute("value", &m_nLaserRange[2]);
// Tier 3
TiXmlElement* laserRangeThree = laserRange->FirstChildElement("tier_three");
laserRangeThree->FirstChildElement("cost")->Attribute("value", &m_nLaserRangeUpgradeCost[2]);
laserRangeThree->FirstChildElement("range")->Attribute("value", &m_nLaserRange[3]);
#pragma endregion
// Load Sounds
SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
m_hSellSound = pAudio->LoadAudio("resource/audio/doorClose.wav");
m_hInvalidSound = pAudio->LoadAudio("resource/audio/invalidPurchase.wav");
m_hMachineGunShotSound = pAudio->LoadAudio("resource/audio/machineGunShot.wav");
m_hMapleSyrupShotSound = pAudio->LoadAudio("resource/audio/mapleSyrupShot.wav");
m_hHockeyStickSlashSound = pAudio->LoadAudio("resource/audio/hockeyStickSlash.wav");
}
示例9: if
/*virtual*/ void Zombie::HandleCollision(const IBase* pOther)
{
SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
if (pOther->GetType() == OBJ_BULLET)
{
const Bullet* bullet = dynamic_cast<const Bullet*>(pOther);
health -= bullet->GetDamage();
if (health <= 0.0f)
{
pAudio->PlayAudio(Game::GetInstance()->zombie_death, false);
this->SetAnimation(this->animation.m_strCurrAnimation + "Death");
this->RetrieveBehavior("wait");
//isAlive = false;
}
else
{
if (pAudio->IsAudioPlaying(Game::GetInstance()->zombie_pain) == false)
pAudio->PlayAudio(Game::GetInstance()->zombie_pain, false);
}
CreateBloodMsg* msg = new CreateBloodMsg(m_ptPosition);
msg->QueueMessage();
msg = nullptr;
}
if (pOther->GetType() == OBJ_EXPLODING_ZOMBIE)
{
const BaseObject* ptr = dynamic_cast<const BaseObject*>(pOther);
if (ptr->GetAnimation() == "bloodExplosion")
{
pAudio->PlayAudio(Game::GetInstance()->zombie_death, false);
this->SetAnimation(this->animation.m_strCurrAnimation + "Death");
this->RetrieveBehavior("wait");
//isAlive = false;
}
}
if (pOther->GetType() == OBJ_BARBEDWIRE_V || pOther->GetType() == OBJ_BARBEDWIRE_H)
{
const BarbedWire* barbWire = dynamic_cast<const BarbedWire*>(pOther);
if (barbWire->IsActive())
{
health -= barbWire->GetDamage() * Game::GetInstance()->DeltaTime();
if (health <= 0)
{
pAudio->PlayAudio(Game::GetInstance()->zombie_death, false);
this->SetAnimation(this->animation.m_strCurrAnimation + "Death");
this->RetrieveBehavior("wait");
//isAlive = false;
}
MovingObject::HandleCollision(pOther);
}
}
if (pOther->GetType() == OBJ_SANDBAG || pOther->GetType() == OBJ_SANDBAG_L || pOther->GetType() == OBJ_SANDBAG_R)
{
const SandBag* sandbag = dynamic_cast<const SandBag*>(pOther);
if (sandbag->IsActive())
MovingObject::HandleCollision(pOther);
}
if (pOther->GetType() == OBJ_LANDMINE)
{
const LandMine* landMine = dynamic_cast<const LandMine*>(pOther);
if (landMine->IsActive())
{
pAudio->PlayAudio(Game::GetInstance()->zombie_death, false);
this->SetAnimation(this->animation.m_strCurrAnimation + "Death");
this->RetrieveBehavior("wait");
//isAlive = false;
}
}
else if (pOther->GetType() == OBJ_WALL)
{
const House* house = dynamic_cast<const House*>(pOther);
if (house->IsActive() == true)
MovingObject::HandleCollision(pOther);
}
else if (pOther->GetType() == OBJ_BASE)
MovingObject::HandleCollision(pOther);
}
示例10: if
// Update
/*virtual*/ void IntroState::Update(float elapsedTime)
{
SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance();
if (IntroTimer.GetTime() < 0.0f)
{
pAudio->StopAudio(m_hEmergency);
Game::GetInstance()->RemoveState();
Game::GetInstance()->AddState(GameplayState::GetInstance());
}
if (IntroTimer.GetTime() < 25.0f)
{
if (ScreenTimer.GetTime() <= 0.0f && IntroTimer.GetTime() > 12.0f)
{
transBack -= 5;
transTextFirst += 5;
ScreenTimer.AddTime(.1f);
}
else if (IntroTimer.GetTime() < 12.0f)
{
if (ScreenTimer.GetTime() < 0.0f)
{
transText += 5;
transTextFirst -= 5;
ScreenTimer.AddTime(.1f);
}
//ScreenTimer.Update(elapsedTime);
}
ScreenTimer.Update(elapsedTime);
}
if (transBack <= 0)
{
transBack = 0;
}
if (transText >= 255)
{
transText = 255;
}
if (transTextFirst >= 255)
{
transTextFirst = 255;
}
if (transTextFirst < 0)
{
transTextFirst = 0;
}
IntroTimer.Update(elapsedTime);
/*
AnimationManager::GetInstance()->Update(animation, elapsedTime);
if (starting_y == 120.0f)
{
Game::GetInstance()->RemoveState();
Game::GetInstance()->AddState(GameplayState::GetInstance());
}
starting_y -= SCROLL_SPEED * elapsedTime;
if (starting_y < 120.0f)
starting_y = 120.0f;
*/
}
示例11: Input
void WeaponManager::Input()
{
SGD::InputManager * pInput = SGD::InputManager::GetInstance();
SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance();
if (pInput->IsKeyPressed(SGD::Key::Q) == true || pInput->IsButtonPressed(0, 4) == true || mousewheel < 0)
{
curIndex--;
if (curIndex < 0)
{
curIndex = m_vWeapons.size() - 1;
}
if (pAudio->IsAudioPlaying(m_hWpnSwitch) == false)
{
pAudio->PlayAudio(m_hWpnSwitch, false);
}
while (m_vWeapons[curIndex]->GetEquipped() != true)
{
curIndex--;
if (curIndex < 0)
{
curIndex = m_vWeapons.size() - 1;
}
}
mousewheel = 0;
}
if (pInput->IsKeyPressed(SGD::Key::E) == true || pInput->IsButtonPressed(0, 5) == true || mousewheel > 0)
{
curIndex++;
if (curIndex > (int)m_vWeapons.size() - 1)
{
curIndex = 0;
}
if (pAudio->IsAudioPlaying(m_hWpnSwitch) == false)
{
pAudio->PlayAudio(m_hWpnSwitch, false);
}
while (m_vWeapons[curIndex]->GetEquipped() != true)
{
curIndex++;
if (curIndex > (int)m_vWeapons.size() - 1)
{
curIndex = 0;
}
}
mousewheel = 0;
}
if (pInput->IsKeyPressed(SGD::Key::R) == true && m_vWeapons[curIndex]->GetCurrAmmo() < m_vWeapons[curIndex]->GetMagSize())
{
//GetSelected()->SetCurrAmmo(0);
GetSelected()->GetReloadTimer().AddTime(GetSelected()->GetReloadTime());
//m_vWeapons[curIndex]->SetCurrAmmo(0);
//m_vWeapons[curIndex]->GetReloadTimer().AddTime(m_vWeapons[curIndex]->GetReloadTime());
}
}
示例12: Update
void Tower::Update(float dt)
{
SGD::InputManager* pInput = SGD::InputManager::GetInstance();
SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
if (m_bSelected)
{
SGD::Point pos = SGD::Point(m_ptPosition.x - 96 - Camera::x, m_ptPosition.y - 128 - Camera::y);
SGD::Point pos2 = pos + SGD::Vector(224, 128);
SGD::Rectangle upgradeOneRect;
upgradeOneRect.left = pos.x + 8;
upgradeOneRect.top = pos.y + 8;
upgradeOneRect.right = pos.x + 108;
upgradeOneRect.bottom = pos.y + 72;
SGD::Rectangle upgradeTwoRect;
upgradeTwoRect.left = pos.x + 116;
upgradeTwoRect.top = pos.y + 8;
upgradeTwoRect.right = pos.x + 216;
upgradeTwoRect.bottom = pos.y + 72;
SGD::Rectangle sellButton;
sellButton.right = pos2.x - 8;
sellButton.bottom = pos2.y - 8;
sellButton.left = pos2.x - 80;
sellButton.top = pos2.y - 32;
if (pInput->GetMousePosition().IsWithinRectangle(upgradeOneRect))
{
if (!m_bHoverOne)
pAudio->PlayAudio(m_pTowerFlyweight->GetClickSound());
m_bHoverOne = true;
}
else
{
m_bHoverOne = false;
}
if (pInput->GetMousePosition().IsWithinRectangle(upgradeTwoRect))
{
if (!m_bHoverTwo)
pAudio->PlayAudio(m_pTowerFlyweight->GetClickSound());
m_bHoverTwo = true;
}
else
{
m_bHoverTwo = false;
}
if (pInput->GetMousePosition().IsWithinRectangle(sellButton))
{
if (!m_bHoverSell)
pAudio->PlayAudio(m_pTowerFlyweight->GetClickSound());
m_bHoverSell = true;
}
else
{
m_bHoverSell = false;
}
}
}