本文整理汇总了C++中sf::Music类的典型用法代码示例。如果您正苦于以下问题:C++ Music类的具体用法?C++ Music怎么用?C++ Music使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Music类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromMemory
bool MusicHandler::LoadFromMemory(const typeAssetID theAssetID, sf::Music& theAsset)
{
// Start with a return result of false
bool anResult = false;
// TODO: Retrieve the const char* pointer to load data from
const char* anData = NULL;
// TODO: Retrieve the size in bytes of the font to load from memory
size_t anDataSize = 0;
// Try to obtain the font from the memory location specified
if(NULL != anData && anDataSize > 0)
{
// Load the image from the memory location specified
#if (SFML_VERSION_MAJOR < 2)
anResult = theAsset.OpenFromMemory(anData, anDataSize);
#else
anResult = theAsset.openFromMemory(anData, anDataSize);
#endif
}
else
{
ELOG() << "MusicHandler::LoadFromMemory(" << theAssetID
<< ") Bad memory location or size!" << std::endl;
}
// Return anResult of true if successful, false otherwise
return anResult;
}
示例2: LoadFromFile
bool MusicHandler::LoadFromFile(const typeAssetID theAssetID, sf::Music& theAsset)
{
// Start with a return result of false
bool anResult = false;
// Retrieve the filename for this asset
std::string anFilename = GetFilename(theAssetID);
// Was a valid filename found? then attempt to load the asset from anFilename
if(anFilename.length() > 0)
{
// Load the asset from a file
#if (SFML_VERSION_MAJOR < 2)
anResult = theAsset.OpenFromFile(anFilename);
#else
anResult = theAsset.openFromFile(anFilename);
#endif
}
else
{
ELOG() << "MusicHandler::LoadFromFile(" << theAssetID
<< ") No filename provided!" << std::endl;
}
// Return anResult of true if successful, false otherwise
return anResult;
}
示例3: playMusic
void SoundEngine::playMusic(sf::Music & Music)
{
if (activeMusic == true)
{
Music.setLoop(true);
Music.setVolume(20);
Music.play();
}
}
示例4: Play
void Music::Play(Music::Setting setting)
{
switch(setting)
{
case MENU:
menu_snd.play();
battle_snd.stop();
break;
case BATTLE:
menu_snd.stop();
battle_snd.play();
break;
}
}
示例5: MouseClick
void MouseClick(sf::RenderWindow &Window, sf::Music &introMusic)
{
int mouseX = Window.GetInput().GetMouseX();
int mouseY = Window.GetInput().GetMouseY();
if(Window.GetInput().IsMouseButtonDown(sf::Mouse::Left) && mouseX >= 350 && mouseX <= 450)
{
if(mouseY > 100 && mouseY < 200)
introMusic.Play();
else if (mouseY > 200 && mouseY < 300)
introMusic.Pause();
else if (mouseY > 300 && mouseY < 400)
introMusic.Stop();
}
}
示例6: HandleSound
void HandleSound(){
/* Handle sound_queue and music */
if( SoundFx.getStatus() == 0 ){ //status : STOPPED
if( !sound_queue.empty() ){
SoundFx.openFromFile( *sound_queue.front() );
SoundFx.play();
sound_queue.pop();
}
}
if( ::SoundMusic.getStatus() == 0 && now_log -> music_path.size() != 0 ){
::SoundMusic.play();
}
}
示例7: Initialize
void Music::Initialize()
{
menu_snd.openFromFile("./Resources/Sounds/menumusic.ogg");
menu_snd.setVolume(60.0f);
menu_snd.setLoop(true);
battle_snd.openFromFile("./Resources/Sounds/battlemusic.ogg");
battle_snd.setVolume(40.0f);
battle_snd.setLoop(true);
menu_snd.play();
}
示例8: ManageSound
void ManageSound() {
assert( now_log != 0 ); // null pointer is unexceptable and there is no solution
//stop whatever Sound Effect playing right now
SoundFx.stop();
//empty the queue if there is still any member on the queue
while( !sound_queue.empty() ) sound_queue.pop();
for( unsigned i = 0; i < now_log -> soundFx_path.size(); ++i ){
sound_queue.push( &(now_log->soundFx_path[i]) );
}
if( now_log -> music_path.size() != 0 ){
SoundMusic.openFromFile( now_log -> music_path );
}
}
示例9: SetVolume
void Music::SetVolume(float32 volume)
{ music.setVolume(volume); }
示例10: InitGL
int InitGL() // All Setup For OpenGL goes here
{
glShadeModel(GL_SMOOTH); // Enables Smooth Shading
glClearColor(0.0, 0.0, 0.0, 1.0);
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Test To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculation
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0); // Uses default lighting parameters
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable(GL_NORMALIZE);
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
glEnable(GL_LIGHT1);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
// and now some init I need to do for other stuff
ilInit(); /* Initialization of DevIL */
// mouse stuff
pointer = toGLTexture("./dati/models/textures/mirino.png");
lastx = middleX;
lasty = middleY;
relativeX = 0.0;
relativeY = 0.0;
glutWarpPointer(middleX, middleY); // put the cursor in the middle of the screen
//for the menu
InitMenu();
// for the text
t3dInit();
// for the skybox
initSkybox();
// for the blend
initAssets();
// for the sounds
if (!sound_hit.loadFromFile("./dati/audio/hit.wav")) return -1;
if (!sound_miss.loadFromFile("./dati/audio/miss.wav")) return -1;
if (!sound_youreempty.loadFromFile("./dati/audio/youreempty.wav")) return -1;
if (!sound_ohno.loadFromFile("./dati/audio/ohno.wav")) return -1;
music.setLoop(true);
if (!music.openFromFile("./dati/audio/Rango_Theme.ogg")) return -1;
music.play();
return TRUE; // Initialization Went OK
}
示例11: newGame
void newGame ()
{
music.stop();
music.openFromFile("./dati/audio/Morricone.ogg");
music.play();
main_camera.setLocRot(locRot(0,0,0,0,0,0));
int j;
t=reset_time(t);
for(j=0; j<18; j++){
m[j]=reset_motion(m[j]);
}
livello=1;
// for the score
score = 0;
gun0.bullet_number = BULLET_NUMBER;
first = TRUE;
return;
}
示例12: init
void init(string path) {
if ( !sound.openFromFile(path) ) {
cout << "error loading music";
return;
}
}
示例13: levelChanger
void levelChanger(void)
{
if (score >= 100) {
if(livello==3){
//musica
music.stop();
music.openFromFile("./dati/audio/Stuck_In_Guacamole.ogg");
music.play();
menu_id=4;
}
else{
changeLevel(UP);
reload();
score = 0;
}
}
return;
}
示例14: tick
static void tick()
{
if(currently_playing.getStatus() == sf::SoundSource::Stopped)
{
current_song++;
swap_to_song_type(ROUND_GENERAL);
}
}
示例15: swap_to_song_type
static void swap_to_song_type(music_purpose new_purpose)
{
if(new_purpose == NONE)
{
currently_playing.stop();
current_song = -1;
return;
}
///at the moment do shit
int new_song = -1;
for(int i=0; i<(int)file_names.size(); i++)
{
int song_offset = (i + current_song) % file_names.size();
music_purpose current_purpose = (music_purpose)purpose[song_offset];
if((current_purpose & new_purpose) > 0)
{
new_song = song_offset;
break;
}
}
if(new_song == -1)
return;
if(new_song == current_song && currently_playing.getStatus() != sf::SoundSource::Stopped)
return;
currently_playing.stop();
currently_playing.openFromFile("res/" + file_names[new_song]);
currently_playing.play();
current_song = new_song;
}