本文整理汇总了C++中IEntitySoundProxy::GetSound方法的典型用法代码示例。如果您正苦于以下问题:C++ IEntitySoundProxy::GetSound方法的具体用法?C++ IEntitySoundProxy::GetSound怎么用?C++ IEntitySoundProxy::GetSound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntitySoundProxy
的用法示例。
在下文中一共展示了IEntitySoundProxy::GetSound方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSoundProxy
//------------------------------------------------------------------------
ISound *CItem::GetISound(tSoundID id)
{
IEntitySoundProxy *pSoundProxy = GetSoundProxy(false);
if (pSoundProxy)
return pSoundProxy->GetSound(id);
return 0;
}
示例2: PlaySound
// add enum of sound you want to play, and add command to game code at appropiate spot
void CGameAudio::PlaySound(EGameAudioSounds eSound, IEntity *pEntity, float param, bool stopSound)
{
int soundFlag = 0; //localActor will get 2D sounds
ESoundSemantic eSemantic = eSoundSemantic_None;
ISound *pSound = NULL;
bool setParam = false;
static string soundName;
soundName.resize(0);
switch(eSound)
{
case EGameAudioSound_NOSOUND:
break;
case EGameAudioSound_LAST:
break;
default:
break;
}
//if(!force3DSound && m_pOwner == m_pGameFramework->GetClientActor() && !m_pOwner->IsThirdPerson() && soundName.size())
//{
// if (bAppendPostfix)
// soundName.append("_fp");
//}
IEntitySoundProxy *pSoundProxy = pEntity ? (IEntitySoundProxy *)pEntity->CreateProxy(ENTITY_PROXY_SOUND) : NULL;
if(soundName.size() && eSound < EGameAudioSound_LAST) //get / create or stop sound
{
if(m_sounds[eSound].ID != INVALID_SOUNDID)
{
if(pSoundProxy)
pSound = pSoundProxy->GetSound(m_sounds[eSound].ID);
else
pSound = gEnv->pSoundSystem->GetSound(m_sounds[eSound].ID);
if(stopSound)
{
if(pSound)
pSound->Stop();
m_sounds[eSound].ID = INVALID_SOUNDID;
return;
}
}
if(!pSound && !stopSound)
{
pSound = gEnv->pSoundSystem->CreateSound(soundName, soundFlag);
if(pSound)
{
pSound->SetSemantic(eSemantic);
//float fTemp = 0.0f;
m_sounds[eSound].ID = pSound->GetId();
m_sounds[eSound].bLooping = (pSound->GetFlags() & FLAG_SOUND_LOOP) != 0;
m_sounds[eSound].b3D = (pSound->GetFlags() & FLAG_SOUND_3D) != 0;
//m_sounds[eSound].nMassIndex = pSound->GetParam("mass", &fTemp, false);
//m_sounds[eSound].nSpeedIndex = pSound->GetParam("speed", &fTemp, false);
//m_sounds[eSound].nStrengthIndex = pSound->GetParam("strength", &fTemp, false);
}
}
}
if(pSound) //set params and play
{
//pSound->SetPosition(m_pOwner->GetEntity()->GetWorldPos());
if(setParam)
{
//if (m_sounds[eSound].nMassIndex != -1)
// pSound->SetParam(m_sounds[sound].nMassIndex, param);
//if (m_sounds[eSound].nSpeedIndex != -1)
// pSound->SetParam(m_sounds[sound].nSpeedIndex, param);
//if (m_sounds[eSound].nStrengthIndex != -1)
// pSound->SetParam(m_sounds[sound].nStrengthIndex, param);
}
if(!(m_sounds[eSound].bLooping && pSound->IsPlaying()))
{
if(pSoundProxy)
pSoundProxy->PlaySound(pSound);
else
pSound->Play();
}
}
}
示例3: PlayAction
//------------------------------------------------------------------------
tSoundID CItem::PlayAction(const ItemString &actionName, int layer, bool loop, uint32 flags, float speedOverride)
{
if(!m_enableAnimations || !IsOwnerInGame())
return (tSoundID)-1;
TActionMap::iterator it = m_sharedparams->actions.find(CONST_TEMPITEM_STRING(actionName));
if(it == m_sharedparams->actions.end())
{
// GameWarning("Action '%s' not found on item '%s'!", actionName, GetEntity()->GetName());
for(int i=0; i<eIGS_Last; i++)
{
m_animationTime[i]=0;
m_animationSpeed[i]=1.0f;
m_animationEnd[i]=0;
}
return 0;
}
bool fp = m_stats.fp;
if(m_parentId)
{
CItem *pParent=static_cast<CItem *>(m_pItemSystem->GetItem(m_parentId));
if(pParent)
fp=pParent->GetStats().fp;
}
if(flags&eIPAF_ForceFirstPerson)
fp = true;
if(flags&eIPAF_ForceThirdPerson)
fp = false;
int sid=fp?eIGS_FirstPerson:eIGS_ThirdPerson;
SAction &action = it->second;
tSoundID result = INVALID_SOUNDID;
if((flags&eIPAF_Sound) && !action.sound[sid].name.empty() && IsSoundEnabled() && g_pGameCVars->i_soundeffects)
{
int nSoundFlags = FLAG_SOUND_DEFAULT_3D;
nSoundFlags |= flags&eIPAF_SoundStartPaused?FLAG_SOUND_START_PAUSED:0;
IEntitySoundProxy *pSoundProxy = GetSoundProxy(true);
//GetSound proxy from dualwield master if neccesary
if(IsDualWieldSlave())
{
CItem *pMaster = static_cast<CItem *>(GetDualWieldMaster());
if(pMaster)
{
pSoundProxy = pMaster->GetSoundProxy(true);
}
}
EntityId pSkipEnts[3];
int nSkipEnts = 0;
// TODO for Marcio :)
// check code changes
// Skip the Item
pSkipEnts[nSkipEnts] = GetEntity()->GetId();
++nSkipEnts;
// Skip the Owner
if(GetOwner())
{
pSkipEnts[nSkipEnts] = GetOwner()->GetId();
++nSkipEnts;
}
if(pSoundProxy)
{
TempResourceName name;
FixResourceName(action.sound[sid].name, name, flags);
//nSoundFlags = nSoundFlags | (fp?FLAG_SOUND_DEFAULT_3D|FLAG_SOUND_RELATIVE:FLAG_SOUND_DEFAULT_3D);
Vec3 vOffset(0,0,0);
if(fp)
vOffset.x = 0.3f; // offset for first person weapon to the front
if(!g_pGameCVars->i_staticfiresounds)
{
result = pSoundProxy->PlaySoundEx(name, vOffset, FORWARD_DIRECTION, nSoundFlags, 1.0f, 0, 0, eSoundSemantic_Weapon, pSkipEnts, nSkipEnts);
ISound *pSound = pSoundProxy->GetSound(result);
if(pSound && action.sound[sid].sphere>0.0f)
pSound->SetSphereSpec(action.sound[sid].sphere);
}
else
{
SInstanceAudio *pInstanceAudio=0;
//.........这里部分代码省略.........