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


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

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


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

示例1: finish

void finish()
{
	RenderWindow window(VideoMode(500,500),"", Style::None);
	Texture text;
	text.loadFromFile("images/finish.png");
	Sprite finish; finish.setTexture(text);
	Music music;
	music.openFromFile("music/finish.ogg");
	music.play();
	
	while(window.isOpen())
    {
		Event event;
		while (window.pollEvent(event))
		{
			if(IntRect(420,461,57,36).contains(Mouse::getPosition(window)))
				{
					if(Mouse::isButtonPressed(Mouse::Left))
					{
						music.stop();
						window.close();
					}
			}

		}
		window.clear();
		window.draw(finish);
		window.display();
	 }
}
开发者ID:DariaDar,项目名称:Reposit,代码行数:30,代码来源:functions.cpp

示例2: processLevelTick

void HelpScreen::processLevelTick(unsigned int millisElapsed) {
	Music *music = (Music*) ResourcesManager::getResource("MenuMusic");
	ButtonItem *backButton = (ButtonItem*) userInterface->getItem("ZBackButton");
	if (backButton->isPressed()) {
		music->stop(500);
		userInterface->startFadeOut(200);
		actionAfterFade = 1;
	}
	if (actionAfterFade > 0 && !userInterface->isFading()) {
		GameMenu *menu = new GameMenu();
		GameApp::getInstance()->setCurrentLevel(menu);
	}

	Level::processLevelTick(millisElapsed);
}
开发者ID:roooodcastro,项目名称:gamedev-coursework,代码行数:15,代码来源:HelpScreen.cpp

示例3: menu

void menu(RenderWindow &window)
 {
	 Texture menuText1, menuText2, menuText3, menuBackground;
	 menuBackground.loadFromFile("images/menu1.jpg");
	 menuText2.loadFromFile("images/cat.jpg");
	 Sprite menuLoad(menuText2);
	 Sprite menuBg(menuBackground);
	 bool isMenu = 1;
	 int menuNum = 0;
	 menuBg.setPosition(0,0);
	 Music music;
	 music.openFromFile("music/menu.ogg");
	 music.play();

	 Font font;
	 font.loadFromFile("dumb.ttf");
	 Text text("", font, 38); text.setStyle(Text::Bold);
	 Text text2("", font, 38); text2.setStyle(Text::Bold);
	 Text text3("", font, 38); text3.setStyle(Text::Bold);
	 text.setString("New Game");
	 text2.setString("Load");
	 text3.setString("Exit");
	 text.setPosition(485, 410);
	 text2.setPosition(550, 450);
	 text3.setPosition(550,568);


	 while(isMenu)
	 {
		text.setColor(Color(254,150,121));
		text2.setColor(Color(254,150,121));
		text3.setColor(Color(254,150,121));
		menuNum = 0;

		 window.clear(Color(129,181,221));
		 //New Game
		 if(IntRect(500,410,200,60).contains(Mouse::getPosition(window)))
		 {
			 text.setColor(Color(98,198,223));
			 menuNum = 1;
		 }
		 //Load Game
		 if(IntRect(550,488,200,60).contains(Mouse::getPosition(window)))
		 {
			 text2.setColor(Color(98,198,223));
			 menuNum = 2;
		 }
		 //Exit
		 if(IntRect(500,564,200,60).contains(Mouse::getPosition(window)))
		 {
			 text3.setColor(Color(98,198,223));
			 menuNum = 3;
		 }


		if(Mouse::isButtonPressed(Mouse::Left))
		{
			if(menuNum == 1)
			{
				music.stop();
				return;
			}
			if(menuNum == 2)
			{
				window.draw(menuLoad);
				window.display();
				while(!Keyboard::isKeyPressed(Keyboard::Escape))
				{;}
			}
			if(menuNum == 3)
			{
				music.stop();
				window.close();
				isMenu = false;
			}
		}
		 window.draw(menuBg);
		 window.draw(text);
		 window.draw(text2);
		 window.draw(text3);
		 window.display();
	 }
 }
开发者ID:DariaDar,项目名称:Reposit,代码行数:83,代码来源:mainProg.cpp

示例4: menu

void Menu::menu(RenderWindow & app, int width, int height) {
	bool musicIsPlaying = true;
	Music music;
	music.openFromFile("sounds/menuMusic.ogg");
	music.setLoop(true);

	Texture menuTexture1, menuTexture2, menuTexture3, aboutTexture, menuBackground;
	menuTexture1.loadFromFile("images/StartGame.png");
	menuTexture2.loadFromFile("images/LeaderBoard.png");
	menuTexture3.loadFromFile("images/exit.png");
	menuBackground.loadFromFile("images/menu.png");
	Sprite menu1(menuTexture1), menu2(menuTexture2), menu3(menuTexture3), menuBg(menuBackground);
	bool isMenu = 1;
	int menuNum = 0;
	menu1.setPosition(400, 300);
	menu2.setPosition(400, 375);
	menu3.setPosition(400, 450);
	menuBg.setPosition(0, 0);

	while (isMenu)
	{
		if (musicIsPlaying)
		{
			music.play();
			musicIsPlaying = false;
		}

		menu1.setColor(Color::White);
		menu2.setColor(Color::White);
		menu3.setColor(Color::White);
		menuNum = 0;
		app.clear(Color(129, 181, 221));

		if (IntRect(400, 300, 300, 50).contains(Mouse::getPosition(app))) 
		{ 
			menu1.setColor(Color::Blue); 
			menuNum = 1; 
		}
		if (IntRect(400, 375, 300, 50).contains(Mouse::getPosition(app))) 
		{
			menu2.setColor(Color::Blue); 
			menuNum = 2; 
		}
		if (IntRect(400, 450, 300, 50).contains(Mouse::getPosition(app))) 
		{
			menu3.setColor(Color::Blue); 
			menuNum = 3; 
		}

		if (Mouse::isButtonPressed(Mouse::Left))
		{
			if (menuNum == 1)
			{
				music.stop();
				const char * filename = "score.txt";
				isMenu = false;
				Game * game = new Game(width, height);
				int score = game->run(app);
				int prevScore;
				ifstream scoreFile;
				scoreFile.open(filename);
				scoreFile >> prevScore;
				scoreFile.close();
				if (score > prevScore)
				{
					ofstream scoreFile;
					scoreFile.open(filename);
					scoreFile << score;
					scoreFile.close();
				}
				isMenu = true;
			}
			//if (menuNum == 2) { window.draw(about); window.display(); while (!Keyboard::isKeyPressed(Keyboard::Escape)); }
			if (menuNum == 3) 
			{ 
				app.close(); isMenu = false; 
			}
			musicIsPlaying = true;
		}

		app.draw(menuBg);
		app.draw(menu1);
		app.draw(menu2);
		app.draw(menu3);
		printTopScore(app);
		app.display();
	}
开发者ID:Armen-Arakelian,项目名称:Armen,代码行数:87,代码来源:Menu.cpp

示例5: main


//.........这里部分代码省略.........

					//Cambiar seleccion de boton
					if (!(Keyboard::isKeyPressed(Keyboard::S) || Keyboard::isKeyPressed(Keyboard::Down)) && (Keyboard::isKeyPressed(Keyboard::W) || Keyboard::isKeyPressed(Keyboard::Up)) && Selected > 0 && !KeyPressed)
					{
						Selected--;
						KeyPressed = true;
					}
					else if ((Keyboard::isKeyPressed(Keyboard::S) || Keyboard::isKeyPressed(Keyboard::Down)) && !(Keyboard::isKeyPressed(Keyboard::W) || Keyboard::isKeyPressed(Keyboard::Up)) && Selected < 1 && !KeyPressed)
					{
						Selected++;
						KeyPressed = true;
					}
					else
					{
						KeyPressed = false;
					};

					if (Selected == 0)
					{
						Jugar.SetON();
						Salir.SetOFF();
					}
					else if (Selected == 1)
					{
						Jugar.SetOFF();
						Salir.SetON();
					};

					if (Keyboard::isKeyPressed(Keyboard::Return) || Keyboard::isKeyPressed(Keyboard::Space))
					{
						if (Selected == 0)
						{
							Screen = 2;
							BgMainMusic.stop();
						}
						else if (Selected == 1)
						{
							window.close();
						};
					};
					break;

				case 2: //Niveles

					//Ajustar camara al jugador
					CamaraPosicion.x = yo.getPosition().x - CamaraMedidas.x / 2;
					CamaraPosicion.y = yo.getPosition().y - CamaraMedidas.y / 2;
					Camara.reset(FloatRect(CamaraPosicion.x, CamaraPosicion.y, CamaraMedidas.x, CamaraMedidas.y));
					//Si la musica no se esta reproduciendo...
					if (LevelMusic.getStatus() != 2)
						LevelMusic.play();

					switch (nivel)
					{
						case 0: //Nivel jugable
							window.setView(Camara);

							for (int i = 0; i < contenedorDeSuelo.size(); i++) //Dibujar escenario
							{
								Tile1.positionOnMap(&contenedorDeSuelo[i]);
								window.draw(Tile1.getSprite());
							};

							//Dibujar la meta
							Meta.setPosition(coordenadasParaGanar.x * 34, coordenadasParaGanar.y * 34);
							window.draw(Meta);
开发者ID:Yostarduck,项目名称:Proyecto1,代码行数:67,代码来源:Source.cpp

示例6: mainLevel


//.........这里部分代码省略.........
	 fList.push_back(brokenLight);
	 fList.push_back(bath);
	 fList.push_back(sink);
	 for(it = fList.begin(); it != fList.end(); it++){
		 it->setSub((void *)&it, writeMess);
	 }

	 int cntMeow = 1, cntGame = 0, click = 0, clickBath = 1, clickSink = 1;
	 bath.isPlayed = true;
	 sink.isPlayed = true;


	  while (window.isOpen())
    {
		
		float time = clock.getElapsedTime().asMicroseconds();
		float sinkTime = gameTimeClock.getElapsedTime().asSeconds();
		if(clickSink < 2)
			gameTimeClock.restart();
		clock.restart();
		time = time/500;
		Vector2i pos = Mouse::getPosition(window);
		
		Event event;
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed)
				window.close();

			if (event.type == Event::MouseButtonPressed)
				if (event.key.code == Mouse::Left){

					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();
开发者ID:DariaDar,项目名称:Reposit,代码行数:67,代码来源:functions.cpp

示例7: onFinish

void HelpScreen::onFinish() {
	Music *music = (Music*) ResourcesManager::getResource("MenuMusic");
	Sound::stopAllSfx();
	music->stop(0);
}
开发者ID:roooodcastro,项目名称:gamedev-coursework,代码行数:5,代码来源:HelpScreen.cpp


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