当前位置: 首页>>代码示例>>C++>>正文


C++ SoundPtr::Play方法代码示例

本文整理汇总了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();
}
开发者ID:citizen-erased,项目名称:asteroids,代码行数:31,代码来源:audio.cpp

示例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;
}
开发者ID:aadarshasubedi,项目名称:beesiege,代码行数:53,代码来源:Bee.cpp


注:本文中的SoundPtr::Play方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。