Playing Targeting Sounds
by Anthony Rosenbaum · in Torque Game Engine · 07/16/2003 (6:14 am) · 0 replies
I have been working on SeekerProjectiles and am at a point now where I need to add some sound. I want the player which is "being targeted" to play a warning sound. But all I get right now is the player who "targets" to play the sound here is my code
from from ShapBaseImageData::updateImageState()
then in Player::updateTargetingSounds()
from from ShapBaseImageData::updateImageState()
...
ShapeBase* target = NULL;//target
Player* playerTarget = NULL;//player target
...
SimSetIterator itr(Sim::getServerTargetSet());
if(!isServerObject())
itr = SimSetIterator(Sim::getClientTargetSet());
for (; *itr; ++itr) {
if ((*itr)->getType() & imageData.lockObjectType) {
ShapeBase* shape = static_cast<ShapeBase*>(*itr);
if((*itr)->getType() & PlayerObjectType)
playerTarget = static_cast<Player*>(*itr)
...
if(playerTarget != NULL)
playerTarget->beingTargeted = true;
else
playerTarget->beingTargeted = false;
...then in Player::updateTargetingSounds()
...
if(beingTargeted)
{
if (mDataBlock->sound[PlayerData::TargetedSound])
{
if (!mTargetedSound)
{
mTargetedSound = alxPlay(mDataBlock->sound[PlayerData::TargetedSound], &getTransform());
alxSourceMatrixF(mTargetedSound, &getTransform());
}
}
}else
{
if(mTargetedSound)
{
alxStop(mTargetedSound);
mTargetedSound = 0;
}
}
...About the author