本文整理汇总了C++中SoundPtr::Play方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundPtr::Play方法的具体用法?C++ SoundPtr::Play怎么用?C++ SoundPtr::Play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundPtr
的用法示例。
在下文中一共展示了SoundPtr::Play方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: playSFX
void Audio::playSFX(const std::string &filename, bool relative, const cml::vector2f &pos, float attenuation, float min_dist)
{
if(sounds.empty())
for(int i = 0; i < 32; i++)
{
SoundPtr s(new sf::Sound());
s->SetVolume(60.0f);
sounds.push_back(s);
}
SoundPtr s;
for(unsigned int i = 0; i < sounds.size(); i++)
if(sounds[i]->GetStatus() == sf::Sound::Stopped)
s = sounds[i];
if(!s)
{
warning("too many sounds");
return;
}
SoundBufferPtr sb = getSoundBuffer(filename);
s->SetRelativeToListener(relative);
s->SetPosition(pos[0], pos[1], 0.0f);
s->SetAttenuation(attenuation);
s->SetMinDistance(min_dist);
s->SetBuffer(*(sb.get()));
s->Play();
}
示例2: DoExtraInits
/**
* Initializes the bee's attributes
*
*
* @return bool
*/
bool Bee::DoExtraInits()
{
if (!GameCharacter::DoExtraInits())
{
return false;
}
// add a health attribute
HealthAttributePtr health = NiNew HealthAttribute(this);
m_fMaxHealth = ConfigurationManager::Get()->bee_initialHealth;
health->Reset(m_fMaxHealth);
AddAttribute(GameCharacter::ATTR_HEALTH, (CharacterAttribute*)health);
// add an armor attribute
AddAttribute(GameCharacter::ATTR_ARMOR, NiNew ArmorAttribute(this));
// add a damage attribute
DamageAttribute* dmg = NiNew DamageAttribute(this);
dmg->Reset(ConfigurationManager::Get()->bee_damage);
AddAttribute(GameCharacter::ATTR_DAMAGE, dmg);
// add an FSMBeeAIControl
AddAttribute(GameCharacter::ATTR_CONTROLLER, NiNew FSMBeeAIControl(this));
// set initial position
m_pActor->setGlobalPosition(GameManager::Get()->
GetQueen()->GetActor()->getGlobalPosition() - NxVec3(50.0, 0.0, 0.0));
SoundPtr sound = ResourceManager::Get()->GetSound(
ResourceManager::RES_SOUND_BEE, this);
if (sound)
{
AddAttribute(GameCharacter::ATTR_SOUND_DEFAULT, (CharacterAttribute*)sound);
sound->Play();
}
AddAttribute(GameCharacter::ATTR_SOUND_1, (CharacterAttribute*) ResourceManager::Get()->GetSound(
ResourceManager::RES_SOUND_BEE_AWAITING, this));
AddAttribute(GameCharacter::ATTR_SOUND_2, (CharacterAttribute*) ResourceManager::Get()->GetSound(
ResourceManager::RES_SOUND_BEE_DYING, this));
// set dampings
m_pActor->setLinearDamping(8.0f);
m_pActor->setAngularDamping(8.0f);
return true;
}