本文整理汇总了C++中sound::Event::Play方法的典型用法代码示例。如果您正苦于以下问题:C++ Event::Play方法的具体用法?C++ Event::Play怎么用?C++ Event::Play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sound::Event
的用法示例。
在下文中一共展示了Event::Play方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoThrusterSounds
void Ship::DoThrusterSounds() const
{
// XXX any ship being the current camera body should emit sounds
// also, ship sounds could be split to internal and external sounds
// XXX sound logic could be part of a bigger class (ship internal sounds)
/* Ship engine noise. less loud inside */
float v_env = (Pi::game->GetWorldView()->GetCameraController()->IsExternal() ? 1.0f : 0.5f) * Sound::GetSfxVolume();
static Sound::Event sndev;
float volBoth = 0.0f;
volBoth += 0.5f*fabs(GetThrusterState().y);
volBoth += 0.5f*fabs(GetThrusterState().z);
float targetVol[2] = { volBoth, volBoth };
if (GetThrusterState().x > 0.0)
targetVol[0] += 0.5f*float(GetThrusterState().x);
else targetVol[1] += -0.5f*float(GetThrusterState().x);
targetVol[0] = v_env * Clamp(targetVol[0], 0.0f, 1.0f);
targetVol[1] = v_env * Clamp(targetVol[1], 0.0f, 1.0f);
float dv_dt[2] = { 4.0f, 4.0f };
if (!sndev.VolumeAnimate(targetVol, dv_dt)) {
sndev.Play("Thruster_large", 0.0f, 0.0f, Sound::OP_REPEAT);
sndev.VolumeAnimate(targetVol, dv_dt);
}
float angthrust = 0.1f * v_env * float(GetAngThrusterState().Length());
static Sound::Event angThrustSnd;
if (!angThrustSnd.VolumeAnimate(angthrust, angthrust, 5.0f, 5.0f)) {
angThrustSnd.Play("Thruster_Small", 0.0f, 0.0f, Sound::OP_REPEAT);
angThrustSnd.VolumeAnimate(angthrust, angthrust, 5.0f, 5.0f);
}
}
示例2: StaticUpdate
void Player::StaticUpdate(const float timeStep)
{
Body *b;
vector3d v;
matrix4x4d m;
if (GetFlightState() == Ship::FLYING) {
switch (m_flightControlState) {
case CONTROL_FIXSPEED:
if (Pi::GetView() == Pi::worldView) PollControls(timeStep);
b = (GetCombatTarget() ? GetCombatTarget() : GetNavTarget());
GetRotMatrix(m);
v = m * vector3d(0, 0, -m_setSpeed);
if (b) v += b->GetVelocityRelativeTo(this->GetFrame());
AIMatchVel(v);
break;
case CONTROL_MANUAL:
if (Pi::GetView() == Pi::worldView) PollControls(timeStep);
break;
case CONTROL_AUTOPILOT:
break;
}
}
Ship::StaticUpdate(timeStep); // also calls autopilot AI
if (m_flightControlState == CONTROL_AUTOPILOT && !AIIsActive()) {
Pi::RequestTimeAccel(1);
SetFlightControlState(CONTROL_MANUAL); //FIXSPEED);
// m_setSpeed = 0;
}
/* This wank probably shouldn't be in Player... */
/* Ship engine noise. less loud inside */
float v_env = (Pi::worldView->GetCamType() == WorldView::CAM_EXTERNAL ? 1.0f : 0.5f);
static Sound::Event sndev;
float volBoth = 0.0f;
volBoth += 0.5f*fabs(GetThrusterState().y);
volBoth += 0.5f*fabs(GetThrusterState().z);
float targetVol[2] = { volBoth, volBoth };
if (GetThrusterState().x > 0.0)
targetVol[0] += 0.5f*(float)GetThrusterState().x;
else targetVol[1] += -0.5f*(float)GetThrusterState().x;
targetVol[0] = v_env * Clamp(targetVol[0], 0.0f, 1.0f);
targetVol[1] = v_env * Clamp(targetVol[1], 0.0f, 1.0f);
float dv_dt[2] = { 4.0f, 4.0f };
if (!sndev.VolumeAnimate(targetVol, dv_dt)) {
sndev.Play("Thruster_large", 0.0f, 0.0f, Sound::OP_REPEAT);
sndev.VolumeAnimate(targetVol, dv_dt);
}
float angthrust = 0.1f * v_env * (float)Pi::player->GetAngThrusterState().Length();
static Sound::Event angThrustSnd;
if (!angThrustSnd.VolumeAnimate(angthrust, angthrust, 5.0f, 5.0f)) {
angThrustSnd.Play("Thruster_Small", 0.0f, 0.0f, Sound::OP_REPEAT);
angThrustSnd.VolumeAnimate(angthrust, angthrust, 5.0f, 5.0f);
}
}
示例3: InitiateHyperjumpTo
Ship::HyperjumpStatus Player::InitiateHyperjumpTo(const SystemPath &dest, int warmup_time, double duration, LuaRef checks) {
HyperjumpStatus status = Ship::InitiateHyperjumpTo(dest, warmup_time, duration, checks);
if (status == HYPERJUMP_OK)
s_soundHyperdrive.Play("Hyperdrive_Charge");
return status;
}
示例4: SetWheelState
//XXX all ships should make this sound
bool Player::SetWheelState(bool down)
{
bool did = Ship::SetWheelState(down);
if (did) {
s_soundUndercarriage.Play(down ? "UC_out" : "UC_in", 1.0f, 1.0f, 0);
}
return did;
}
示例5: SetWheelState
bool Player::SetWheelState(bool down)
{
static Sound::Event sndev;
bool did = Ship::SetWheelState(down);
if (did) {
sndev.Play(down ? "UC_out" : "UC_in", 1.0f, 1.0f, 0);
}
return did;
}
示例6: StartHyperspaceCountdown
Ship::HyperjumpStatus Player::StartHyperspaceCountdown(const SystemPath &dest)
{
HyperjumpStatus status = Ship::StartHyperspaceCountdown(dest);
if (status == HYPERJUMP_OK)
s_soundHyperdrive.Play("Hyperdrive_Charge");
return status;
}
示例7: OnEnterHyperspace
//XXX ui stuff
void Player::OnEnterHyperspace()
{
s_soundHyperdrive.Play("Hyperdrive_Jump");
SetNavTarget(0);
SetCombatTarget(0);
Pi::game->GetWorldView()->HideTargetActions(); // hide the comms menu
m_controller->SetFlightControlState(CONTROL_MANUAL); //could set CONTROL_HYPERDRIVE
ClearThrusterState();
Pi::game->WantHyperspace();
}
示例8: Update
void AmbientSounds::Update()
{
float v_env = (Pi::worldView->GetActiveCamera()->IsExternal() ? 1.0f : 0.5f) * Sound::GetSfxVolume();
if (Pi::player->GetFlightState() == Ship::DOCKED) {
if (starNoise.IsPlaying()) {
float target[2] = {0.0f,0.0f};
float dv_dt[2] = {1.0f,1.0f};
starNoise.VolumeAnimate(target, dv_dt);
starNoise.SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
if (atmosphereNoise.IsPlaying()) {
float target[2] = {0.0f,0.0f};
float dv_dt[2] = {1.0f,1.0f};
atmosphereNoise.VolumeAnimate(target, dv_dt);
atmosphereNoise.SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
if (planetSurfaceNoise.IsPlaying()) {
float target[2] = {0.0f,0.0f};
float dv_dt[2] = {1.0f,1.0f};
planetSurfaceNoise.VolumeAnimate(target, dv_dt);
planetSurfaceNoise.SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
if (!stationNoise.IsPlaying()) {
const char *sounds[] = {
"Large_Station_ambient",
"Medium_Station_ambient",
"Small_Station_ambient"
};
// just use a random station noise until we have a
// concept of 'station size'
stationNoise.Play(sounds[Pi::player->GetDockedWith()->GetSystemBody()->seed % 3],
0.3f*v_env, 0.3f*v_env, Sound::OP_REPEAT);
}
} else if (Pi::player->GetFlightState() == Ship::LANDED) {
/* Planet surface noise on rough-landing */
if (starNoise.IsPlaying()) {
float target[2] = {0.0f,0.0f};
float dv_dt[2] = {1.0f,1.0f};
starNoise.VolumeAnimate(target, dv_dt);
starNoise.SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
if (atmosphereNoise.IsPlaying()) {
float target[2] = {0.0f,0.0f};
float dv_dt[2] = {1.0f,1.0f};
atmosphereNoise.VolumeAnimate(target, dv_dt);
atmosphereNoise.SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
if (stationNoise.IsPlaying()) {
float target[2] = {0.0f,0.0f};
float dv_dt[2] = {1.0f,1.0f};
stationNoise.VolumeAnimate(target, dv_dt);
stationNoise.SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
// lets try something random for the time being
if (!planetSurfaceNoise.IsPlaying()) {
SystemBody *sbody = Pi::player->GetFrame()->GetSystemBodyFor();
assert(sbody);
const char *sample = NULL;
if (sbody->m_life > fixed(1,5)) {
const char *s[] = {
"Wind", "Thunder_1", "Thunder_2", "Thunder_3",
"Thunder_4", "Storm", "Rain_Light", "River",
"RainForestIntroducedNight", "RainForestIntroduced",
"NormalForestIntroduced"
};
sample = s[sbody->seed % 11];
}
else if (sbody->m_volatileGas > fixed(1,2)) {
const char *s[] = {
"Wind", "Thunder_1", "Thunder_2", "Thunder_3",
"Thunder_4", "Storm"
};
sample = s[sbody->seed % 6];
}
else if (sbody->m_volatileGas > fixed(1,10)) {
sample = "Wind";
}
if (sample) {
planetSurfaceNoise.Play(sample, 0.3f*v_env, 0.3f*v_env, Sound::OP_REPEAT);
}
}
} else if (planetSurfaceNoise.IsPlaying()) {
// planetSurfaceNoise.IsPlaying() - if we are out of the atmosphere then stop playing
if (Pi::player->GetFrame()->m_astroBody) {
Body *astro = Pi::player->GetFrame()->m_astroBody;
if (astro->IsType(Object::PLANET)) {
double dist = Pi::player->GetPosition().Length();
double pressure, density;
static_cast<Planet*>(astro)->GetAtmosphericState(dist, &pressure, &density);
if (pressure < 0.001) {
// Stop playing surface noise once out of the atmosphere
planetSurfaceNoise.Stop();
}
}
}
//.........这里部分代码省略.........
示例9: Update
void AmbientSounds::Update()
{
const float v_env = (Pi::worldView->GetCameraController()->IsExternal() ? 1.0f : 0.5f) * Sound::GetSfxVolume();
if (Pi::player->GetFlightState() == Ship::DOCKED) {
if (s_starNoise.IsPlaying()) {
const float target[2] = {0.0f,0.0f};
const float dv_dt[2] = {1.0f,1.0f};
s_starNoise.VolumeAnimate(target, dv_dt);
s_starNoise.SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
for(int i=0; i<eMaxNumAtmosphereSounds; i++) {
if (s_atmosphereNoises[i].IsPlaying()) {
const float target[2] = {0.0f,0.0f};
const float dv_dt[2] = {1.0f,1.0f};
s_atmosphereNoises[i].VolumeAnimate(target, dv_dt);
s_atmosphereNoises[i].SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
}
if (s_planetSurfaceNoise.IsPlaying()) {
const float target[2] = {0.0f,0.0f};
const float dv_dt[2] = {1.0f,1.0f};
s_planetSurfaceNoise.VolumeAnimate(target, dv_dt);
s_planetSurfaceNoise.SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
if (!s_stationNoise.IsPlaying()) {
// just use a random station noise until we have a
// concept of 'station size'
s_stationNoise.Play(s_stationNoiseSounds[Pi::player->GetDockedWith()->GetSystemBody()->GetSeed() % NUM_STATION_SOUNDS],
0.3f*v_env, 0.3f*v_env, Sound::OP_REPEAT);
}
} else if (Pi::player->GetFlightState() == Ship::LANDED) {
/* Planet surface noise on rough-landing */
if (s_starNoise.IsPlaying()) {
const float target[2] = {0.0f,0.0f};
const float dv_dt[2] = {1.0f,1.0f};
s_starNoise.VolumeAnimate(target, dv_dt);
s_starNoise.SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
for(int i=0; i<eMaxNumAtmosphereSounds; i++) {
if (s_atmosphereNoises[i].IsPlaying()) {
const float target[2] = {0.0f,0.0f};
const float dv_dt[2] = {1.0f,1.0f};
s_atmosphereNoises[i].VolumeAnimate(target, dv_dt);
s_atmosphereNoises[i].SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
}
if (s_stationNoise.IsPlaying()) {
const float target[2] = {0.0f,0.0f};
const float dv_dt[2] = {1.0f,1.0f};
s_stationNoise.VolumeAnimate(target, dv_dt);
s_stationNoise.SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
// lets try something random for the time being
if (!s_planetSurfaceNoise.IsPlaying()) {
const SystemBody *sbody = Pi::player->GetFrame()->GetSystemBody();
assert(sbody);
const char *sample = 0;
if (sbody->GetLifeAsFixed() > fixed(1,5)) {
sample = s_surfaceLifeSounds[sbody->GetSeed() % NUM_SURFACE_LIFE_SOUNDS];
}
else if (sbody->GetVolatileGasAsFixed() > fixed(1,2)) {
sample = s_surfaceSounds[sbody->GetSeed() % NUM_SURFACE_DEAD_SOUNDS];
}
else if (sbody->GetVolatileGasAsFixed() > fixed(1,10)) {
sample = "Wind";
}
if (sample) {
s_planetSurfaceNoise.Play(sample, 0.3f*v_env, 0.3f*v_env, Sound::OP_REPEAT);
}
}
} else if (s_planetSurfaceNoise.IsPlaying()) {
// s_planetSurfaceNoise.IsPlaying() - if we are out of the atmosphere then stop playing
if (Pi::player->GetFrame()->IsRotFrame()) {
const Body *astro = Pi::player->GetFrame()->GetBody();
if (astro->IsType(Object::PLANET)) {
const double dist = Pi::player->GetPosition().Length();
double pressure, density;
static_cast<const Planet*>(astro)->GetAtmosphericState(dist, &pressure, &density);
if (pressure < 0.001) {
// Stop playing surface noise once out of the atmosphere
s_planetSurfaceNoise.Stop();
}
}
}
} else {
if (s_stationNoise.IsPlaying()) {
const float target[2] = {0.0f,0.0f};
const float dv_dt[2] = {1.0f,1.0f};
s_stationNoise.VolumeAnimate(target, dv_dt);
s_stationNoise.SetOp(Sound::OP_REPEAT | Sound::OP_STOP_AT_TARGET_VOLUME);
}
if (Pi::game->IsNormalSpace()) {
StarSystem *s = Pi::game->GetSpace()->GetStarSystem().Get();
if (astroNoiseSeed != s->GetSeed()) {
// change sound!
//.........这里部分代码省略.........
示例10: StaticUpdate
void Player::StaticUpdate(const float timeStep)
{
vector3d v;
matrix4x4d m;
Ship::StaticUpdate(timeStep); // also calls autopilot AI
if (GetFlightState() == Ship::FLYING) {
switch (m_flightControlState) {
case CONTROL_FIXSPEED:
if (Pi::GetView() == Pi::worldView) PollControls(timeStep);
if (IsAnyThrusterKeyDown()) break;
GetRotMatrix(m);
v = m * vector3d(0, 0, -m_setSpeed);
if (m_setSpeedTarget) {
v += m_setSpeedTarget->GetVelocityRelTo(GetFrame());
}
AIMatchVel(v);
break;
case CONTROL_MANUAL:
if (Pi::GetView() == Pi::worldView) PollControls(timeStep);
break;
case CONTROL_AUTOPILOT:
if (AIIsActive()) break;
Pi::game->RequestTimeAccel(Game::TIMEACCEL_1X);
// AIMatchVel(vector3d(0.0)); // just in case autopilot doesn't...
// actually this breaks last timestep slightly in non-relative target cases
AIMatchAngVelObjSpace(vector3d(0.0));
if (GetFrame()->IsRotatingFrame()) SetFlightControlState(CONTROL_FIXSPEED);
else SetFlightControlState(CONTROL_MANUAL);
m_setSpeed = 0.0;
break;
}
}
else SetFlightControlState(CONTROL_MANUAL);
/* This wank probably shouldn't be in Player... */
/* Ship engine noise. less loud inside */
float v_env = (Pi::worldView->GetCamType() == WorldView::CAM_EXTERNAL ? 1.0f : 0.5f) * Sound::GetSfxVolume();
static Sound::Event sndev;
float volBoth = 0.0f;
volBoth += 0.5f*fabs(GetThrusterState().y);
volBoth += 0.5f*fabs(GetThrusterState().z);
float targetVol[2] = { volBoth, volBoth };
if (GetThrusterState().x > 0.0)
targetVol[0] += 0.5f*float(GetThrusterState().x);
else targetVol[1] += -0.5f*float(GetThrusterState().x);
targetVol[0] = v_env * Clamp(targetVol[0], 0.0f, 1.0f);
targetVol[1] = v_env * Clamp(targetVol[1], 0.0f, 1.0f);
float dv_dt[2] = { 4.0f, 4.0f };
if (!sndev.VolumeAnimate(targetVol, dv_dt)) {
sndev.Play("Thruster_large", 0.0f, 0.0f, Sound::OP_REPEAT);
sndev.VolumeAnimate(targetVol, dv_dt);
}
float angthrust = 0.1f * v_env * float(Pi::player->GetAngThrusterState().Length());
static Sound::Event angThrustSnd;
if (!angThrustSnd.VolumeAnimate(angthrust, angthrust, 5.0f, 5.0f)) {
angThrustSnd.Play("Thruster_Small", 0.0f, 0.0f, Sound::OP_REPEAT);
angThrustSnd.VolumeAnimate(angthrust, angthrust, 5.0f, 5.0f);
}
}
示例11: AbortHyperjump
void Player::AbortHyperjump()
{
s_soundHyperdrive.Play("Hyperdrive_Abort");
Ship::AbortHyperjump();
}
示例12: ResetHyperspaceCountdown
void Player::ResetHyperspaceCountdown()
{
s_soundHyperdrive.Play("Hyperdrive_Abort");
Ship::ResetHyperspaceCountdown();
}