本文整理汇总了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();
}
示例2: playMusic
void SoundEngine::playMusic(sf::Music & Music)
{
if (activeMusic == true)
{
Music.setLoop(true);
Music.setVolume(20);
Music.play();
}
}
示例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 );
}
}
示例4: setVolume
void setVolume(float _volume=1.0f) {
volume = _volume;
int intVol = _volume*100.0f;
sound.setVolume(intVol);
}
示例5: SetVolume
void Music::SetVolume(float32 volume)
{ music.setVolume(volume); }
示例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);
//.........这里部分代码省略.........
示例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();
示例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;
//.........这里部分代码省略.........
示例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));
}
示例10: main_resource_init
void main_resource_init(){
SoundMusic.setVolume( MUSIC_VOLUME );
}