本文整理汇总了C++中Music::pause方法的典型用法代码示例。如果您正苦于以下问题:C++ Music::pause方法的具体用法?C++ Music::pause怎么用?C++ Music::pause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Music
的用法示例。
在下文中一共展示了Music::pause方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mainLevel
//.........这里部分代码省略.........
if (fish.rect.contains(pos.x, pos.y) && key.isPlayed == true){
mainSong.stop();
finish();
window.close();
}
if (cat.sprite.getGlobalBounds().contains(pos.x, pos.y))
{
cntMeow++;
if(cntMeow == 5)
{
meow2.play();
cntMeow = 0;
}
else
meow1.play();
}
toys.trueMove(pos);
if(light.isPlayed == false) light.trueMove(pos);
if(ball.isPlayed == true && books.isPlayed == true) key.trueMove(pos);
if(puddle.isPlayed == true) mop.trueMove(pos);
click = light.clickedThings(pos);
clickBath = bath.clickedThings(pos);
clickSink = sink.clickedThings(pos);
if (upShelf.sprite.getGlobalBounds().contains(pos.x, pos.y)){
skyrim.play();
}
if (mus.rect.contains(pos.x, pos.y)){
muse.play();
}
if (girl.sprite.getGlobalBounds().contains(pos.x, pos.y) && cat.room == 2){
mainSong.pause();
gameOver();
mainSong.play();
}
if(mou.isPlayed == false)
{
if (mou.sprite.getGlobalBounds().contains(pos.x, pos.y))
{
mainSong.pause();
mouseS.play();
//gameRunning();
mou.isPlayed = true;
mainSong.play();
}
}
if(books.isPlayed == false)
{
if (books.sprite.getGlobalBounds().contains(pos.x, pos.y))
{
mainSong.pause();
MiniGame_Books();
books.isPlayed = true;
mainSong.play();
}
}
}
if (event.type == Event::MouseButtonReleased)
if (event.key.code == Mouse::Left){
toys.isMove = false;
key.isMove = false;
if(light.isPlayed == false) light.isMove = false;
示例2: menu
void menu(sf::RenderWindow & window) {
Music music;//создаем объект музыки
music.openFromFile("bg_music.wav");//загружаем файл
music.play();//воспроизводим музыку
music.setLoop(true);
char *fname = "high_score.txt";
FILE * fp;
fp=fopen(fname,"r");
Font font;
int hsT=0;
int hsS=0;
int hsC=0;
fscanf(fp,"%i", &hsT);
fscanf(fp,"%i", &hsS);
fscanf(fp,"%i", &hsC);
font.loadFromFile("game_over.ttf");
Texture menuBackground;
menuBackground.loadFromFile("images/background.jpg");
Text menu1("Start tetris " , font, 20);
Text menu2("Start snake " , font, 20);
Text menu3("Start tetroCar " , font, 20);
Text menu4("High score " , font, 20);
Text menu5("Music " , font, 20);
Text menu6("Exit " , font, 20);
Sprite menuBg(menuBackground);
bool isMenu = 1;
int menuNum = 1;
int stat=1;
menu1.setPosition(120, 80);
menu2.setPosition(120, 120);
menu3.setPosition(120, 160);
menu4.setPosition(120, 200);
menu5.setPosition(120, 240);
menu6.setPosition(120, 280);
menuBg.setPosition(0, 0);
menu5.setColor(Color::Magenta);
while (isMenu)
{
if(menuNum!=1)
menu1.setColor(Color::Magenta);
else menu1.setColor(Color::Blue);
if(menuNum!=2)
menu2.setColor(Color::Magenta);
else menu2.setColor(Color::Blue);
if(menuNum!=3)
menu3.setColor(Color::Magenta);
else menu3.setColor(Color::Blue);
if(menuNum!=4)
menu4.setColor(Color::Magenta);
else menu4.setColor(Color::Blue);
if(menuNum!=6)
menu6.setColor(Color::Magenta);
else menu6.setColor(Color::Blue);
window.clear(Color(129, 181, 221));
if (IntRect(120, 80, 220, 20).contains(Mouse::getPosition(window))) { menu1.setColor(Color::Blue); menuNum = 1; }
if (IntRect(120, 120, 220, 20).contains(Mouse::getPosition(window))) { menu2.setColor(Color::Blue); menuNum = 2; }
if (IntRect(120, 160, 220, 20).contains(Mouse::getPosition(window))) { menu3.setColor(Color::Blue); menuNum = 3; }
if (IntRect(120, 200, 220, 20).contains(Mouse::getPosition(window))) { menu4.setColor(Color::Blue); menuNum = 4; }
if (IntRect(120, 240, 220, 20).contains(Mouse::getPosition(window))) { menuNum = 5; }
if (IntRect(120, 280, 200, 20).contains(Mouse::getPosition(window))) { menu6.setColor(Color::Blue); menuNum = 6; }
sf::Event event;
while (window.pollEvent(event)){
if (event.type == sf::Event::Closed){
freopen(fname, "w",fp);
fprintf(fp,"%i\n", hsT);
fprintf(fp,"%i\n", hsS);
fprintf(fp,"%i\n", hsC);
fclose(fp);
window.close();
return;
}
if(event.type == sf::Event::KeyPressed&&event.key.code==sf::Keyboard::Up){
if(menuNum==1)
menuNum=6;
else menuNum--;
}
if(event.type == sf::Event::KeyPressed&&event.key.code==sf::Keyboard::Down){
if(menuNum==6)
menuNum=1;
else menuNum++;
}
if (Mouse::isButtonPressed(Mouse::Left)||(event.type == sf::Event::KeyPressed&&event.key.code==sf::Keyboard::Return))
{
if (menuNum == 1) {hsT=GameT(window,hsT);}
if (menuNum == 2) {hsS=snake(window,hsS);};
if (menuNum == 3) {hsC=GameTc(window, hsC);}
if (menuNum == 4) hshow(window, hsT, hsS, hsC);
if (menuNum == 5) {if(stat==1){
menu5.setColor(Color::Blue);
music.pause();
stat=0;
}else {
menu5.setColor(Color::Magenta);
music.play();
stat=1;
}
}
if (menuNum == 6) {
window.close();
//.........这里部分代码省略.........