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


C++ Music::setVolume方法代码示例

本文整理汇总了C++中sf::Music::setVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ Music::setVolume方法的具体用法?C++ Music::setVolume怎么用?C++ Music::setVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sf::Music的用法示例。


在下文中一共展示了Music::setVolume方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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

示例2: 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

示例3: Init

	/*
		PRIVATE function are not supposed to be called from outside VisualNovel namespace
		even though it's accessible from global.
		it can lead to errors if called
	*/
	void Init(){
		//get the image for the text's background
		log_background = get_image( "resource/LogBackground.png" );

		//set the volume to the default global volume
		SoundFx.setVolume( MUSIC_VOLUME ); 
		
		static bool loaded = false;
		if( !loaded ) //to prevent double calling
		{
			font_display.loadFromFile( "resource/PTN57F.ttf" );

			log_text_display.setFont( font_display );
			log_text_display.setCharacterSize( 24 );
			log_text_display.setColor( sf::Color( 255, 255, 255 ) );
			log_text_display.setPosition( log_x + log_padding_x, log_y + log_padding_y );

			log_name_display.setFont( font_display );
			log_name_display.setCharacterSize( 40 );
			log_name_display.setColor( sf::Color( 255, 255, 255 ) );
			log_name_display.setPosition( log_x + log_padding_x, log_y - log_to_name_y - 40 );
		}
	}
开发者ID:rmxhaha,项目名称:phantasia,代码行数:28,代码来源:VisualNovel.cpp

示例4: setVolume

		void setVolume(float _volume=1.0f) {
			volume = _volume;
			int intVol = _volume*100.0f;
			sound.setVolume(intVol);
		}
开发者ID:BrendanBuono,项目名称:voxelquestiso,代码行数:5,代码来源:f00294_gamemusic.hpp

示例5: SetVolume

	void Music::SetVolume(float32 volume)
	{ music.setVolume(volume); }
开发者ID:Shoduler,项目名称:AxLib,代码行数:2,代码来源:Music.hpp

示例6: while

int screen_1::Run(sf::RenderWindow &App)
{
    hop.setBuffer(hopFile);
    trucked.setBuffer(truckedFile);
    dunked.setBuffer(dunkedFile);
    
    // Clock
    sf:: Clock clock;
    sf::Time time;
    sf::Time delay;
    
    // Plays Intro
    intro.play();
    delay = intro.getDuration();
    
    time = clock.getElapsedTime();
    // Music
    while ( clock.getElapsedTime() <= delay )
    {
        //cout << "NO";
    }
    froggerTheme.setVolume(50);
    froggerTheme.play();
    clock.restart();
    
    sf::Event Event;
    
    bool Running = true;
    int sum = 0;// for log testing purposes
    int sum2 = 0;
    int sum3 = 0;
    int sum4 = 0;
    int sum5 = 0;
    int sum6 = 0;
    int sum7 = 0;
    int sum8 = 0;
    int sum9 = 0;
    int sum10 = 0;
    
    while (Running)
    {
        // Timer Rect and Clock
        double time = clock.getElapsedTime().asSeconds();
        
        if(time >= 1.5)
        {
            timeRect.width = timeRect.width - 2.383;
            timer.setTextureRect(timeRect);
            clock.restart();
        }
        
        if(timeRect.width <= 0)
        {
            frogOnLily1 = false;
            frogOnLily2 = false;
            frogOnLily3 = false;
            frogOnLily4 = false;
            frogOnLily5 = false;
            mainPlayer.setNumLives(3);
            rectSource.width = 115;
            life.setTextureRect(rectSource);
            occupied1.setPosition(-100, -100);
            occupied2.setPosition(-100, -100);
            occupied3.setPosition(-100, -100);
            occupied4.setPosition(-100, -100);
            occupied5.setPosition(-100, -100);
            froggerTheme.pause();
            clock.restart();
            timeRect.width = 143;
            timer.setTextureRect(timeRect);
            frogger.setPosition(320, 605);
            
            return 2;
        }
        // *********************************************************************
        // Creating the objects of Object class for continuous movement
        //
        // Object(double posX, double posY, double speed)
        // *********************************************************************
        // Trucks
        Object t1(130, 420,0.2 );
        Object t2(550, 290, 0.2);
        // Cars
        Object c1(-50, 420, 0.3);
        Object c2(280, 289, 0.2);
        Object c3(0, 289, 0.2);
        // Short Logs
        Object sl1(0, 125, 0.2);
        Object sl2(200, 61, 0.3);
        Object sl3(300, 8, 0.4);
        // Long Logs
        Object l1(799, 8.3, 0.4);
        Object l2(500, 125, 0.2);
        
        // Sets object's direction
        t1.moveRight(truck);
        t2.moveLeft(truck2);
        c1.moveRight(car);
        c2.moveLeft(car2);
        c3.moveLeft(car3);
//.........这里部分代码省略.........
开发者ID:EmilyGarcia,项目名称:Frogger,代码行数:101,代码来源:screen_1.hpp

示例7: main


//.........这里部分代码省略.........
    // Animation wird hizugefügt: Muss nicht wiederholt werden.
    animationList.push_back(&schallAnimation);

    // Zoombegrenzung
    int zoomLevel = 0;

    // Input delay
    sf::Clock verzoegerung;

    // Musik
    string vorherigesLevel = "hauptmenu";
    hintergrundMusik("hauptmenu");

    // rand initialisieren (Zufallsseed aus der Zeit lesen)
    srand(time(0x0));

    sf::Sound schritt;
    sf::SoundBuffer schrittbuffer;
    schrittbuffer.loadFromFile("resources/sound/Schritte.wav");
    schritt.setBuffer(schrittbuffer);
    schritt.play();
    schritt.setLoop(true);

    // Solange das Fenster geöffnet ist:
    while(fenster.isOpen())
    {
        // Hat sich das Level geändert?
        if(aktuellesLevel->name != vorherigesLevel)
        {
            // Je nach Level entsprechende Musik abspielen
            if(aktuellesLevel->name == "hauptmenu")
            {
                hintergrundMusik("hauptmenu");
                musik.setVolume(50);
            }

            else if(aktuellesLevel->name == "gameOver")
            {
                hintergrundMusik("gameover");
                musik.setVolume(50);
            }

            else
            {
                // Wenn weder Menü noch Gameover -> main Musik
                hintergrundMusik("main");
                musik.setVolume(100);
            }

            // Zum Überprüfen nächstes Mal
            vorherigesLevel = aktuellesLevel->name;
        }


        // Eingabeüberprüfung!
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
        {
            // Bei Escape Hauptmenü laden
            // Gespeicherte Levels zurücksetzen
            for(auto l: levelListe)
            {
                cout << "Level '" << l.first << "' aus Speicher entfernt\n";
                delete l.second;
            }
            cout << "Alle " << levelListe.size() << " Level entfernt\n";
            levelListe.clear();
开发者ID:Galaxy2,项目名称:Projektarbeit,代码行数:67,代码来源:main.cpp

示例8: tick

void ambiance::tick(int madness)
{
	ambMadness = 101-madness;
	ambMaxVolume = 100;

	// SO THE ENGINE BEGINS //

		// IF NOT PLAYING AA ///////////////////////////////////////////////////
		
		if (ALLambAA[ambAARandom].getStatus() == 0)
		{
			// FILE SELECTOR //
			ambAARandom = rand()% ARRAY_SIZE(ambAAFile);
			//ALLambAA[ambAARandom].openFromFile(ambAAFile[ambAARandom]);

			// VOLUME RESET //
			ALLambAA[ambAARandom].setVolume(0);
			ambAAVolume = 0;
			ambAADynamics = 100000;

			// LENGTH //
			ambAALength = rand() % 60 + 40;
			ambAASecCounter = 0;

			// FADE //
			ambAAFadeSpeed = rand()% 2 + 3;
			ambAAFadeOut = false;

			// PITCH //
			ambAAPitch = rand() % 100;
			ambAAPitch = ambAAPitch/200+0.75;
			ALLambAA[ambAARandom].setPitch(ambAAPitch);
				
			// PLAY //
			ALLambAA[ambAARandom].play();
		}

		// IF NOT PLAYING AB /////////////////////////////////////////////////////////

		if (ALLambAB[ambABRandom].getStatus() == 0)
		{
			// FILE SELECTOR //
			ambABRandom = rand()% ARRAY_SIZE(ambABFile);
			//ALLambAB[ambABRandom].openFromFile(ambABFile[ambABRandom]);

			// VOLUME RESET //
			ALLambAB[ambABRandom].setVolume(0);
			ambABVolume = 0;
			ambABDynamics = 100000;

			// LENGTH //
			ambABLength = rand() % 30 + 30;
			ambABSecCounter = 0;

			// FADE //
			ambABFadeSpeed = rand()% 2 + 3;
			ambABFadeOut = false;

			// PITCH //
			ambABPitch = rand() % 100;
			ambABPitch = ambABPitch/200+0.75;
			ALLambAB[ambABRandom].setPitch(ambABPitch);
				
			// PLAY //
			ALLambAB[ambABRandom].play();
		}
		
		// FADE AA ////////////////////////////////////////////////////////////////
		
		// COUNTERS //

		ambAAFrameCounter++;

		if (ambAAFrameCounter>60)
		{
			ambAAFrameCounter = 0;
			ambAASecCounter++;
		}

		// FADE //

		if (ALLambAB[ambABRandom].getStatus() == 2)
		{
			ambAADynamics = 10000*(ambMadness*0.25/100) + 2500;

			// FADE VOLUME UP //

			if (ambAAVolume + ambAAFadeSpeed < ambAADynamics && ambAAFadeOut == false)
			{
				ambAAVolume = ambAAVolume + ambAAFadeSpeed;

				ambAAIntToFloat = ambAAVolume;
				ALLambAA[ambAARandom].setVolume(ambAAIntToFloat/100*(ambMaxVolume/100));
			}

			// FADE VOLUME DOWN //

			else if (ambAAVolume > ambAADynamics && ambAAFadeOut == false)
			{
				ambAAVolume = ambAAVolume - ambAAFadeSpeed*2;
//.........这里部分代码省略.........
开发者ID:Sebbish,项目名称:Lucid,代码行数:101,代码来源:ambiance.cpp

示例9:

ambiance::ambiance()
{
// INSTANCES D //

	ambDA.setVolume(0);
	ambDA.setLoop(false); 

	ambDB.setVolume(70);
	ambDB.setLoop(false); 

	ambDC.setVolume(100);
	ambDC.setLoop(false);

	ambDD.setVolume(100);
	ambDD.setLoop(false);

	ambDA.openFromFile(path+"ambDA01.ogg");
	ambDB.openFromFile(path+"ambDB01.ogg");
	ambDC.openFromFile(path+"ambDC01.ogg");
	ambDD.openFromFile(path+"ambDD01.ogg");

	// LOAD ALL FILES (AKA RONNYHAX) ////////////////////////////////////////////


	for(int i = 0; i < ARRAY_SIZE(ambAAFile); i++)
	{
		ALLambAA[i].openFromFile(path+ambAAFile[i]);
		ALLambAA[i].setVolume(0);
		ALLambAA[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambABFile); i++)
	{
		ALLambAB[i].openFromFile(path+ambABFile[i]);
		ALLambAB[i].setVolume(0);
		ALLambAB[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambBAFile); i++)
	{
		ALLambBA[i].openFromFile(path+ambBAFile[i]);
		ALLambBA[i].setVolume(0);
		ALLambBA[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambBBFile); i++)
	{
		ALLambBB[i].openFromFile(path+ambBBFile[i]);
		ALLambBB[i].setVolume(0);
		ALLambBB[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambBCFile); i++)
	{
		ALLambBC[i].openFromFile(path+ambBCFile[i]);
		ALLambBC[i].setVolume(0);
		ALLambBC[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambCAFile); i++)
	{
		ALLambCA[i].openFromFile(path+ambCAFile[i]);
		ALLambCA[i].setVolume(0);
		ALLambCA[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambCBFile); i++)
	{
		ALLambCB[i].openFromFile(path+ambCBFile[i]);
		ALLambCB[i].setVolume(0);
		ALLambCB[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambCCFile); i++)
	{
		ALLambCC[i].openFromFile(path+ambCCFile[i]);
		ALLambCC[i].setVolume(0);
		ALLambCC[i].setLoop(true); 
	}
	// RAND TIME & ARRAYLENGTH DEFINITION //
		srand (time(0));	
}
开发者ID:Sebbish,项目名称:Lucid,代码行数:82,代码来源:ambiance.cpp

示例10: main_resource_init

void main_resource_init(){
	SoundMusic.setVolume( MUSIC_VOLUME );
}
开发者ID:rmxhaha,项目名称:phantasia,代码行数:3,代码来源:VisualNovel.cpp


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