当前位置: 首页>>代码示例>>C++>>正文


C++ sf::Music类代码示例

本文整理汇总了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;
  }
开发者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: 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

示例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;
}
开发者ID:licnep,项目名称:RangoShooter,代码行数:27,代码来源:main.cpp

示例12: init

		void init(string path) {
			if ( !sound.openFromFile(path) ) {
				cout << "error loading music";
				return;
			}
			
		}
开发者ID:BrendanBuono,项目名称:voxelquestiso,代码行数:7,代码来源:f00294_gamemusic.hpp

示例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;
}
开发者ID:licnep,项目名称:RangoShooter,代码行数:18,代码来源:main.cpp

示例14: tick

    static void tick()
    {
        if(currently_playing.getStatus() == sf::SoundSource::Stopped)
        {
            current_song++;

            swap_to_song_type(ROUND_GENERAL);
        }
    }
开发者ID:20k,项目名称:SwordFight,代码行数:9,代码来源:music.hpp

示例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;
    }
开发者ID:20k,项目名称:SwordFight,代码行数:39,代码来源:music.hpp


注:本文中的sf::Music类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。