本文整理汇总了C++中sf::Music类的典型用法代码示例。如果您正苦于以下问题:C++ Music类的具体用法?C++ Music怎么用?C++ Music使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Music类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Moltov,项目名称:Time-Voyager,代码行数:29,代码来源:MusicHandler.cpp
示例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;
}
开发者ID:Moltov,项目名称:Time-Voyager,代码行数:27,代码来源:MusicHandler.cpp
示例3: playMusic
void SoundEngine::playMusic(sf::Music & Music)
{
if (activeMusic == true)
{
Music.setLoop(true);
Music.setVolume(20);
Music.play();
}
}
开发者ID:merche-o,项目名称:CommunistSharkApocalypse,代码行数:9,代码来源:SoundEngine.cpp
示例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;
}
}
开发者ID:vsrz,项目名称:VHH,代码行数:14,代码来源:music.cpp
示例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();
}
}
开发者ID:CodingMadeEasy,项目名称:Sfml-1.6,代码行数:14,代码来源:Tut27.cpp
示例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();
}
}
开发者ID:rmxhaha,项目名称:phantasia,代码行数:16,代码来源:VisualNovel.cpp
示例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();
}
开发者ID:vsrz,项目名称:VHH,代码行数:11,代码来源:music.cpp
示例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 );
}
}
开发者ID:rmxhaha,项目名称:phantasia,代码行数:16,代码来源:VisualNovel.cpp
示例9: SetVolume
void Music::SetVolume(float32 volume)
{ music.setVolume(volume); }
开发者ID:Shoduler,项目名称:AxLib,代码行数:2,代码来源:Music.hpp
示例10: Load
bool Music::Load(const String& fileName)
{ return music.openFromFile(fileName.ptr); }
开发者ID:Shoduler,项目名称:AxLib,代码行数:2,代码来源:Music.hpp
示例11: GetDurationInSeconds
float32 Music::GetDurationInSeconds()
{ return music.getDuration().asSeconds(); }
开发者ID:Shoduler,项目名称:AxLib,代码行数:2,代码来源:Music.hpp
示例12: ResumeMenu
void TWindows :: ResumeMenu(sf::RenderWindow& oknoAplikacji, bool& skip, sf::Music& Gmusic, int TGmusic)
{
while( oknoAplikacji.isOpen() )
{
//CZYSZCZENIE OKNA
EventsWin(oknoAplikacji, tribe, option, skip, 1);
if(skip==true)
if(TGmusic!=-1)
{
Gmusic.stop();
}
sf::Texture textur;
bool viewtext=textur.loadFromFile("tloczarne.png");
if(viewtext==true)
{
sf::Sprite blackpic;
blackpic.setColor(sf::Color(0, 0, 0, 125));
blackpic.setTexture(textur);
blackpic.setScale(10,10);
oknoAplikacji.draw(blackpic);
}
sf::Font czcionka;
sf::Text costam,costam1, costam2;
if(czcionka.loadFromFile("XG-pixo.ttf"))
{
costam.setFont(czcionka);
//TEXT W MENU TYTULOWYM
costam.setString("*PAUSE*");
costam.setCharacterSize(60);
//costam.setStyle(sf::Text::Bold);
costam.setPosition(100, 50);
costam.setScale(2,2);
costam.setColor(sf::Color(255,255,255));
oknoAplikacji.draw(costam);
//RESUME
costam.setString("RESUME");
costam.setCharacterSize(20);
//costam.setStyle(sf::Text::Bold);
costam.setPosition(295, 300);
costam.setScale(2,2);
if(option==0)
{
costam.setColor(sf::Color(125,125,125));
}
else
{
costam.setColor(sf::Color(255,255,255));
}
oknoAplikacji.draw(costam);
//EXIT
costam.setString("EXIT");
if(option==0)
{
costam.setColor(sf::Color(255,255,255));
}
else
{
costam.setColor(sf::Color(125,125,125));
}
costam.setPosition(340, 350);
oknoAplikacji.draw(costam);
}
oknoAplikacji.display();
if(tribe==1 || skip==true)
break;
}
oknoAplikacji.clear(sf::Color( 10, 10, 10 ));
tribe=0;
option=0;
}
开发者ID:WakeCaine,项目名称:TeTTris,代码行数:74,代码来源:TWindows.cpp
示例13: TAPES
namespace music
{
enum music_purpose : uint32_t
{
NONE = 0,
ROUND_START = 1,
ROUND_GENERAL = 2,
ROUND_NEAR_END = 4, ///time low. Dynamically calculate which song to play based on time left
ROUND_END = 8,
MAIN_MENU = 16,
VICTORY = 32,
DEFEAT = 64,
LOW_HP = 128,
DRAMATIC = 256,
ROUND_SPANNING = 512 ///maybe instead of this, chop life support up into 2 clips?
/*METEOR = 1,
INDOORS = 2,
GENERAL = 4,
BADTHING = 8,
GOODTHING = 16,
LOWAIR = 32,
GAMEOVER = 64,
RETRY = 128,
GAMESTART = 256,
MAINMENU = 512*/
};
/*static std::vector<std::string> file_names =
{
"Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 01 Castlecool.flac",
"Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 11 Strutters.flac",
"Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 06 Search for Legitimacy.flac", ///need to adjust start
"Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 07 Run!.flac",
"Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 12 Life Support.flac",
"Sam_Berrow - HEART AND SOUL -EP- - 02 Maniacle Monacle.flac",
"Sam_Berrow - THE EMPLOYMENT TAPES (PART I) - 06 Indilgent.flac"
};*/
///Maybe I should only have music at the start and end of rounds? And when stuff happens?
///need to get search for legitimacy but without the continuation
static std::vector<std::string> file_names
{
"Sam_Berrow - THE EMPLOYMENT TAPES (PART I) - 06 Indilgent.flac", ///start, general
"Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 05 Brain Journey.flac", ///general. Also for dramatic things
"Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 07 Run!.flac", ///near_end, low_hp, or potentially general
"Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 11 Strutters.flac", ///general? Not sure on this one
"Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 14 Trash (Trash.).flac", ///start really
"Sam_Berrow - HEART AND SOUL -EP- - 02 Maniacle Monacle.flac", ///general?
"Sam_Berrow - THE EMPLOYMENT TAPES (PART I) - 10 Fenk.flac", /// can definitely use the first 8 seconds of this
"Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 01 Castlecool.flac", ///could use this is something dramatic happens
"Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 12 Life Support.flac" ///only use this if I can have it span across two rounds
};
static std::vector<uint32_t> purpose
{
ROUND_START | ROUND_GENERAL,
DRAMATIC | ROUND_GENERAL,
LOW_HP,
ROUND_GENERAL,
ROUND_START,
ROUND_START | ROUND_GENERAL,
VICTORY,
DRAMATIC,
ROUND_SPANNING
};
/*static std::vector<uint32_t> purpose =
{
GENERAL | INDOORS, ///use bitflag
GENERAL,
GOODTHING,
LOWAIR,
GAMEOVER | RETRY,
GENERAL | GAMESTART,
METEOR | MAINMENU
};*/
extern int current_song;
extern sf::Music currently_playing;
static std::string get_current_song_name()
{
if(current_song < 0 || current_song >= (int)file_names.size())
return "";
return file_names[current_song];
}
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;
//.........这里部分代码省略.........
开发者ID:20k,项目名称:SwordFight,代码行数:101,代码来源:music.hpp
示例14: SetPitch
void Music::SetPitch(float32 pitch)
{ music.setPitch(pitch); }
开发者ID:Shoduler,项目名称:AxLib,代码行数:2,代码来源:Music.hpp
示例15: SetLooping
void Music::SetLooping(bool isLooping)
{ music.setLoop(isLooping); }
开发者ID:Shoduler,项目名称:AxLib,代码行数:2,代码来源:Music.hpp
示例16: Stop
void Music::Stop()
{ music.stop(); }
开发者ID:Shoduler,项目名称:AxLib,代码行数:2,代码来源:Music.hpp
示例17: Play
void Music::Play()
{ music.play(); }
开发者ID:Shoduler,项目名称:AxLib,代码行数:2,代码来源:Music.hpp
示例18: Pause
void Music::Pause()
{ music.pause(); }
开发者ID:Shoduler,项目名称:AxLib,代码行数:2,代码来源:Music.hpp
示例19: SetPosition
void Music::SetPosition(float32 seconds)
{ music.setPlayingOffset(sf::Time(sf::seconds(seconds))); }
开发者ID:Shoduler,项目名称:AxLib,代码行数:2,代码来源:Music.hpp
示例20: 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
}
开发者ID:licnep,项目名称:RangoShooter,代码行数:60,代码来源:main.cpp
注:本文中的sf::Music类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论