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


C++ RenderWindow::SetFramerateLimit方法代码示例

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


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

示例1: Run

void EngineGraphic::Run(sf::RenderWindow &App, config &configuration)
{
    //Créer la fenêtre
    MyImageManager.build(configuration);
    App.Create(VideoMode(LARGEUR_FENETRE+120,HAUTEUR_FENETRE,32),"SFML moteur 2D");
    App.SetFramerateLimit(60);
}
开发者ID:JyBP,项目名称:Shoot-Em-Up-cpp,代码行数:7,代码来源:EngineGraphic.cpp

示例2: run

void MainMenuHandler::run(sf::RenderWindow& window) {
	ImageCache mainMenuImages;
	const sf::Image& logoImage = mainMenuImages.get(Path::findDataPath("graphics/logo.png"));

	// Entering main menu, no game should be running.
	GameHandler::instance.reset();

	// Make view that is as close to 640x480 as possible and centered.
	view = window.GetDefaultView();
	view.Zoom(std::min(view.GetRect().GetWidth() / 640, view.GetRect().GetHeight() / 480));
	view.SetCenter(view.GetHalfSize());
	window.SetView(view);

	window.SetFramerateLimit(30);

	// Position at the top of the window.
	sf::Sprite logoSprite(logoImage);
	logoSprite.SetCenter(logoImage.GetWidth() / 2, 0);
	logoSprite.SetPosition(window.GetView().GetRect().GetWidth() / 2, 1);

	// Build the main menu GUI.
	GUI::Container gui;
	gui.insert(boost::shared_ptr<GUI::Object>(new GUI::Button("New game", 200, 100, 240, 50, boost::bind(&MainMenuHandler::startGame, this))));
	gui.insert(boost::shared_ptr<GUI::Object>(new GUI::Button("Exit", 250, 170, 140, 50, boost::bind(&sf::RenderWindow::Close, boost::ref(window)))));

	menuClosed = false;
	while (window.IsOpened() && !menuClosed) {
		sf::Event e;
		if (window.GetEvent(e)) {
			if (gui.handleEvent(e, window)) {
				continue;
			}
			if (e.Type == sf::Event::Closed || (e.Type == sf::Event::KeyPressed && e.Key.Code == sf::Key::Escape)) {
				window.Close();
				continue;
			}
		} else {
			window.Clear(sf::Color(0xcc, 0x66, 0x33));
			window.Draw(logoSprite);
			gui.draw(window);
			window.Display();
		}
	}
}
开发者ID:Pumpuli,项目名称:PutkaRTS,代码行数:44,代码来源:MainMenuHandler.cpp

示例3: Run


//.........这里部分代码省略.........
					selected--;
				else
					selected = 3;
			}

			//Joystick
			if((Event.Type == sf::Event::JoyMoved) && (Event.JoyMove.JoystickId == 0))
			{
				if((Event.JoyMove.Axis == sf::Joy::Axis::AxisX) || (Event.JoyMove.Axis == sf::Joy::Axis::AxisY))
				{
					if(Event.JoyMove.Position == 100)
					{
						if(selected != 3)
							selected++;
						else
							selected = 1;
					}
					if(Event.JoyMove.Position == -100)
					{
						if(selected != 1)
							selected--;
						else
							selected = 3;
					}
				}
			}

			if((Event.Type == sf::Event::JoyButtonPressed) && (Event.JoyMove.JoystickId == 0))
			{
				switch(selected)
				{
				case 1:
					return(SCREEN_SETUP);
					break;
				case 2:
					return(SCREEN_COMMAND);
					break;
				case 3:
					return(SCREEN_EXIT);
					break;
				}
			}



			if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Return))
			{
				switch(selected)
				{
				case 1:
					return(SCREEN_SETUP);
					break;
				case 2:
					return(SCREEN_COMMAND);
					break;
				case 3:
					return(SCREEN_EXIT);
					break;
				}
			}

			//Update

			switch(selected)
			{
			case 1:
				menuPlay.SetColor(sf::Color(0,255,0));
				menuCommandes.SetColor(sf::Color(255,255,255));
				menuQuit.SetColor(sf::Color(255,255,255));
				menuPlay.SetSize(37);
				menuCommandes.SetSize(35);
				menuQuit.SetSize(35);
				break;
			case 2:
				menuPlay.SetColor(sf::Color(255,255,255));
				menuCommandes.SetColor(sf::Color(255,255,0));
				menuQuit.SetColor(sf::Color(255,255,255));
				menuPlay.SetSize(35);
				menuCommandes.SetSize(37);
				menuQuit.SetSize(35);
				break;
			case 3:
				menuPlay.SetColor(sf::Color(255,255,255));
				menuCommandes.SetColor(sf::Color(255,255,255));
				menuQuit.SetColor(sf::Color(255,0,0));
				menuPlay.SetSize(35);
				menuCommandes.SetSize(35);
				menuQuit.SetSize(37);
				break;
			}


		}

		Draw(App);
		App.SetFramerateLimit(FPS);

	}

}
开发者ID:thomasfantou,项目名称:Bomberman,代码行数:101,代码来源:ScreenMenu.cpp


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