本文整理汇总了C++中sf::Music::pause方法的典型用法代码示例。如果您正苦于以下问题:C++ Music::pause方法的具体用法?C++ Music::pause怎么用?C++ Music::pause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Music
的用法示例。
在下文中一共展示了Music::pause方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例2: 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);
//.........这里部分代码省略.........
示例3: update
void update(sf::RectangleShape floor[], sf::RectangleShape road[], int floorWidth, int floorHeightPosition, sf::Sprite& rrSprite, double &pos, bool &jumpStatus,
bool& isoverlap, std::stringstream &ss, sf::Clock &clock, sf::Text &textTime, sf::Music& roadrunnerMusic, sf::Music& sanicMusic, sf::Sound& squawkSound,
bool& deathStatus, sf::Sprite& sanicSprite, sf::Sprite& sanicPowerupSprite, bool& sanicPowerupStatus, int& globalSpeed, sf::Time& sanicTime, bool& powerupSpawnStatus,
sf::Time& powerupSpawnTimer, sf::Sprite arrayOfObjectSprite[], bool& boulderSpawnStatus, int numObject, int objStop, sf::Sound& jumpSound, sf::RectangleShape backgroundbox[])
{
//game timer
if (!isoverlap)
{
sf::Time time1 = clock.getElapsedTime();
ss.str(std::string());
ss << setprecision(2) << fixed << static_cast<double>(time1.asSeconds());
textTime.setString(ss.str().c_str());
}
// Return to roadrunner character
if (clock.getElapsedTime() >= sanicTime && sanicPowerupStatus)
{
sanicMusic.pause();
roadrunnerMusic.play();
sanicPowerupStatus = false;
}
// How fast everything moves
if (sanicPowerupStatus && (clock.getElapsedTime() <= sanicTime - sf::seconds(1))) //sanic run speed
globalSpeed = 100;
else
globalSpeed = 15; //roadrunner run speed
// Powerup spawner, checks every 10 seconds
if (clock.getElapsedTime() >= powerupSpawnTimer)
{
powerupSpawnTimer += sf::seconds(10); //time to spawn for every consecutive powerup after the first
powerupSpawnStatus = true;
}
// Powerup spawn chance
if (powerupSpawnStatus)
{
if (rand() % 100 <= 33) // 33% chance to spawn
{
sanicPowerupSprite.setScale(0.05, 0.05);
sanicPowerupSprite.setPosition(floorWidth, 250);
}
powerupSpawnStatus = false;
}
// Sanicpowerup movement, how fast the icon moves
if (sanicPowerupSprite.getPosition().x >= objStop)
sanicPowerupSprite.move(-globalSpeed, 0);
// Roadrunner and sanicpowerup collision
if (overlap(rrSprite, sanicPowerupSprite) && !sanicPowerupStatus)
{
roadrunnerMusic.pause();
sanicMusic.play();
sanicPowerupStatus = true;
sanicTime = clock.getElapsedTime() + sf::seconds(10);
sanicPowerupSprite.setScale(0, 0);
}
//Infinite floor/road
floor[0].move(-globalSpeed, 0);
floor[1].move(-globalSpeed, 0);
road[0].move(-globalSpeed, 0);
road[1].move(-globalSpeed, 0);
if (floor[0].getPosition().x <= -floorWidth)
{
floor[0].setPosition(0, floorHeightPosition);
floor[1].setPosition(floorWidth, floorHeightPosition);
road[0].setPosition(0, floorHeightPosition);
road[1].setPosition(floorWidth, floorHeightPosition);
}
//backgroundbox, movement, infinite background
if (sanicPowerupStatus && (clock.getElapsedTime() <= sanicTime - sf::seconds(1)))
{
backgroundbox[0].move(-globalSpeed / 2 + 10, 0);
backgroundbox[1].move(-globalSpeed / 2 + 10, 0);
}
else
{
backgroundbox[0].move(-globalSpeed + 10, 0);
backgroundbox[1].move(-globalSpeed + 10, 0);
}
if (backgroundbox[0].getPosition().x <= -floorWidth)
{
backgroundbox[0].setPosition(0, -100);
backgroundbox[1].setPosition(floorWidth, -100);
}
// Roadrunner jump
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) && rrSprite.getPosition().y >= 505)
{
jumpStatus = true;
jumpSound.play();
//.........这里部分代码省略.........
示例4: main
int main(int argc, char** argv){
if (argc != 7) {
cerr << "Wrong call\n";
return 1;
}
// [Dirtracker][PortTracker][NodoActualDir][NodoActualPort][DirFiles][Delay]
// ./Client localhost 5555 localhost 6666 Temp 5
string TrackerDir=argv[1];
string TrackerPort=argv[2];
string NodeDir=argv[3];
string NodePort=argv[4];
string TrackerConnect="tcp://"+TrackerDir+":"+TrackerPort;
string NodeListenerConnect="tcp://*:"+NodePort;
string NodeDirSite="tcp://"+NodeDir+":"+NodePort;
Tpath= argv[5];
cout<<"Path: "<<Tpath<<endl;
int Time = atoi(argv[6]);
zctx_t* context = zctx_new();
void* Tracker = zsocket_new(context, ZMQ_DEALER);
int a = zsocket_connect(Tracker, TrackerConnect.c_str());
cout << "connecting to Tracker: "<<TrackerConnect << (a == 0 ? " OK" : "ERROR") << endl;
cout << "Listening! Tracker" << endl;
void* NodeListener = zsocket_new(context, ZMQ_ROUTER);
int b = zsocket_bind(NodeListener,NodeListenerConnect.c_str());
cout << "Listening! Nodes at : "<<NodeListenerConnect << (b == 0 ? " OK" : "ERROR") << endl;
zmq_pollitem_t items[] = {{Tracker, 0, ZMQ_POLLIN, 0},
{NodeListener, 0, ZMQ_POLLIN, 0}};
DirFiles(Tpath);
SplitFiles(Tpath);
DirFiles(Tpath);
RegPeer(Tracker,NodeDirSite);
thread Poll(PollItems,Tracker,NodeListener,items,context,NodeDirSite);
Poll.detach();
for(int i=0;i<FileList.size();i++){
cout<<"Item ["<<i<<"]: "<<FileList[i]<<endl;
}
int op=0;
while(op!=7){
cout<<"LL iii lll ' TTTTTTT tt"<<endl;
cout<<"LL lll ''' TTT oooo rr rr rr rr eee nn nnn tt"<<endl;
cout<<"LL iii lll '' TTT oo oo rrr r rrr r ee e nnn nn tttt"<<endl;
cout<<"LL iii lll TTT oo oo rr rr eeeee nn nn tt"<<endl;
cout<<"LLLLLLL iii lll TTT oooo rr rr eeeee nn nn tttt"<<endl;
cout<<"::::::::::::::::::::::::::::::"<<endl;
cout<<":::::::: MENU :::::::::"<<endl;
cout<<"::::::::::::::::::::::::::::::"<<endl;
cout<<":: 1-> Search :::"<<endl;
cout<<":: 2-> Download :::"<<endl;
cout<<":: 3-> Play Song (sin extensión) :::"<<endl;
cout<<":: 4-> Pause :::"<<endl;
cout<<":: 5-> Stop :::"<<endl;
cout<<":: 6-> Play in memory :::"<<endl;
cout<<":: 7-> Exit :::"<<endl;
cin>>op;
switch (op){
case 1 :
QuerySearch(Tracker);
break;
case 2 :
QueryListFile(Tracker);
break;
case 3 :
Save.lock();
if(Cont1!=Cont2){
cout<<"No se puede reproducir, canción incompleta , \n ¡espera hasta que se termine de descargar!"<<endl;
}else{
string Song;
cin>>Song;
string sentence= "7z x Temp/"+Song+".7z.001";
system(sentence.c_str());
if(music.openFromFile("Temp/"+Song+".ogg")){
music.stop();
music.play();
}
}
Save.unlock();
break;
case 4 :
music.pause();
break;
case 5 :
//.........这里部分代码省略.........
示例5: handleKeypress
// ----------------------------------------------------------------------------
//Called when a key is pressed
void handleKeypress(unsigned char key, //The key that was pressed
int x, int y)
{ //The current mouse coordinates
float xrotrad, yrotrad;
switch (key) {
case 'f':
case 'F':
if(full_screen){
full_screen=FALSE;
f_s_off=TRUE;
}
else full_screen=TRUE;
break;
case 'r':
case 'R':
reload();
break;
case 32://Space key
if(menu && menu_id==0)menu_id=2; //metti menu credits
break;
case 'c':
case 'C':
if(menu && menu_id==0)menu_id=1; //metti menu comandi
break;
case 13: //Enter key
if(menu_id==0){
menu_id=5; //Inizia a Giocare (Esci dai menu!)
newGame();
menu=FALSE;
}
break;
case 8: //Backspace key
if(!pause){
if(menu_id==4){
music.stop();
music.openFromFile("./dati/audio/Rango_Theme.ogg");
music.play();
}
menu_id=0;//Torna al menu pricipale
menu=TRUE;
}
break;
case 'p':
case 'P':
if(menu && menu_id==0)menu_id=3; //metti menu personaggi
break;
case 's':
case 'S':
if(menu_id==5){
if(pause) {
music_pause.stop();
music.play();
pause=FALSE;
}
else {
//musica
music.pause();
music_pause.openFromFile("./dati/audio/Lizard.ogg");
music_pause.play();
pause=TRUE;
}
}
break;
case 27: //Escape key
exit(0); //Exit the program
}
}