本文整理汇总了C++中SoundManager::PlaySound方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundManager::PlaySound方法的具体用法?C++ SoundManager::PlaySound怎么用?C++ SoundManager::PlaySound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundManager
的用法示例。
在下文中一共展示了SoundManager::PlaySound方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Tick
void Player::Tick()
{
if (GlobalInput->IsKeyDown(sf::Key::Left))
{
//Velocity.x = -4;
Acceleration.x = -Accel;
if (Physic != PHYS_Landed && fabs(Velocity.x)>=4)
Acceleration.x*=AirControl;
Direction=-1;
}
else if (GlobalInput->IsKeyDown(sf::Key::Right))
{
//Velocity.x = 4;
Acceleration.x = Accel;
if (Physic != PHYS_Landed && fabs(Velocity.x)>=4 )
Acceleration.x*=AirControl;
Direction=1;
}
else
{
if (fabs(Velocity.x)>0.5)
{
Acceleration.x = -sign(Velocity.x)*.25;
if (Physic != PHYS_Landed )
Acceleration.x*=AirControl;
}
else
{
Velocity.x = 0;
Acceleration.x=0;
}
}
if (GlobalInput->IsKeyDown(sf::Key::Space) && Physic == PHYS_Landed && !Level->GetBlockAt(GridLocationExt + vec2i(0,-1)).bSolid)
{
Physic = PHYS_Jumping;
Velocity.y = -8;
PlayAnimation("jump");
MaxJumpHeight = Location.y - 60;
SM.PlaySound(*JumpSound);
}
if (Physic == PHYS_Jumping && (!GlobalInput->IsKeyDown(sf::Key::Space) || (Location.y+Velocity.y < MaxJumpHeight)))
Physic = PHYS_Falling;
if (Physic == PHYS_Landed)
{
if (Velocity.x ==0)
PlayAnimation("idle");
else
{
if (Direction == sign(Velocity.x))
PlayAnimation("walk");
else
PlayAnimation("turn");
}
}
vec2f & C = Level->GetCameraLocation();
int S = Velocity.x==0 ? Direction : sign(Velocity.x);
if ( (S<0 && Location.x+Velocity.x < C.x ) || (S>0 && Location.x+Velocity.x+16 > C.x + 320))
{
Velocity.x = 0;
Acceleration.x=0;
}
C.x = Location.x-160;
C.y = Location.y-224;
EntityBase::Tick();
}
示例2: main
int main ()
{
printf ("Results of test 'test':\n");
try
{
Timer timer (bind (&Application::Exit, 0), TEST_WORK_TIME);
srand ((unsigned int)time (NULL));
SoundManager manager ("OpenAL", "*");
Listener listener;
Emitter emitter;
emitter.SetSource ("declaration1");
emitter.SetSampleIndex (rand ());
/*
Testing basic manager properties
*/
printf ("Initial volume = %f,", manager.Volume ());
manager.SetVolume (0.7f);
printf (" new volume = %f.\n", manager.Volume ());
printf ("Initial mute: "); print (manager.IsMuted ());
manager.SetMute (true);
printf ("Mute: "); print (manager.IsMuted ());
manager.SetMute (false);
printf ("Mute: "); print (manager.IsMuted ());
printf ("Initial listener status: "); print (manager.Listener ());
listener.position = vec3f (0.f, 1.f, 0.f);
listener.direction = vec3f (0.f, 0.f, 1.f);
listener.up = vec3f (0.f, -1.f, 0.f);
listener.velocity = vec3f (1.f, 0.f, 0.f);
manager.SetListener (listener);
printf ("New listener status: "); print (manager.Listener ());
manager.LoadSoundLibrary (library_file);
/*
Testing basic emitter properties
*/
printf ("Emitter source - %s\n", emitter.Source ());
printf ("Initial emitter volume = %f,", emitter.Volume ());
emitter.SetVolume (0.9f);
printf (" new emitter volume = %f.\n", emitter.Volume ());
printf ("Initial position: "); print (emitter.Position ());
printf ("\nInitial direction: "); print (emitter.Direction ());
printf ("\nInitial velocity: "); print (emitter.Velocity ());
emitter.SetPosition (vec3f (-50.f, 2.f, 4.f));
emitter.SetDirection (vec3f (-2.f, -2.f, -4.f));
emitter.SetVelocity (vec3f (0.f, 0.f, 0.1f));
printf ("\nNew position: "); print (emitter.Position ());
printf ("\nNew direction: "); print (emitter.Direction ());
printf ("\nNew velocity: "); print (emitter.Velocity ()); printf ("\n");
/*
Testing manager work
*/
manager.PlaySound (emitter, 0.3f);
printf ("Current offset in seconds = %f\n", manager.Tell (emitter));
printf ("Duration in seconds = %f\n", manager.Duration (emitter));
printf ("Looping = %c\n", manager.IsLooping (emitter) ? 'y' : 'n');
printf ("Is Playing = %c\n", manager.IsPlaying (emitter) ? 'y' : 'n');
Timer timer2 (bind (&TimerHandler, ref (emitter)), ACTION_TIME);
Application::Run ();
}
catch (std::exception& exception)
{
printf ("exception: %s\n",exception.what ());
}
catch (...)
{
printf ("unknown exception\n");
}
printf ("exit\n");
return Application::GetExitCode ();
}
示例3: Land
void Player::Land()
{
SM.PlaySound(*LandSound);
}