本文整理汇总了C++中sf::RenderWindow::Display方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderWindow::Display方法的具体用法?C++ RenderWindow::Display怎么用?C++ RenderWindow::Display使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::RenderWindow
的用法示例。
在下文中一共展示了RenderWindow::Display方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showCredits
void showCredits(sf::RenderWindow& app)
{
Credits credit(app);
//Credits loop
while (app.IsOpened()) {
//Process events
sf::Event Event;
//Window closed
while (app.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
app.Close();
//Escape key pressed
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
app.Close();
}
if (credit.showCredits())
{
app.Clear();
credit.update();
app.Display();
continue;
}
else
{
break;
}
}
}
示例2: Show
MainMenu::MenuResult MainMenu::Show(sf::RenderWindow& window)
{
//Load menu image from file
sf::Image image;
image.LoadFromFile("images/mainmenu.png");
sf::Sprite sprite(image);
//Setup clickable regions
//Play menu item coordinates
MenuItem playButton;
playButton.rect.Top= 145;
playButton.rect.Bottom = 380;
playButton.rect.Left = 0;
playButton.rect.Right = 1023;
playButton.action = Play;
//Exit menu item coordinates
MenuItem exitButton;
exitButton.rect.Left = 0;
exitButton.rect.Right = 1023;
exitButton.rect.Top = 383;
exitButton.rect.Bottom = 560;
exitButton.action = Exit;
_menuItems.push_back(playButton);
_menuItems.push_back(exitButton);
window.Draw(sprite);
window.Display();
return GetMenuResponse(window);
}
示例3: Show
void SplashScreen::Show(sf::RenderWindow & renderWindow)
{
sf::Image image;
if(image.LoadFromFile("images/SplashScreen.png") != true)
{
return;
}
sf::Sprite sprite(image);
renderWindow.Draw(sprite);
renderWindow.Display();
sf::Event event;
while(true)
{
while(renderWindow.GetEvent(event))
{
if (event.Type == sf::Event::KeyPressed ||
event.Type == sf::Event::MouseButtonPressed ||
event.Type == sf::Event::Closed)
{
return;
}
}
}
} // End Show
示例4: draw
void draw(){
_window.Clear();
{
sf::Rect<float> frect = sf::Rect<float>(0,0,window_width,window_height);
_camera.SetFromRect(frect);
}
_window.Draw(_backgroundSprite);
// draw the range shade
_rangeSprite.SetPosition(current_pose.x + window_width/2, window_height/2 - current_pose.y);
_window.Draw(_rangeSprite);
// draw the landmarks
for(unsigned int i=0; i<landmarks.size(); i++){
_landmarkSprite.SetPosition(landmarks[i].x + window_width/2, window_height/2 - landmarks[i].y);
_window.Draw(_landmarkSprite);
}
// draw the robot
_robotSprite.SetPosition(current_pose.x + window_width/2, window_height/2 - current_pose.y);
_robotSprite.SetRotation(current_pose.theta * 180 / M_PI);
_window.Draw(_robotSprite);
// draw the "other" robot
_fakeRobotSprite.SetPosition(fake_current_pose.x + window_width/2, window_height/2 - fake_current_pose.y);
_fakeRobotSprite.SetRotation(fake_current_pose.theta * 180 / M_PI);
_window.Draw(_fakeRobotSprite);
// display everything
_window.Display();
}
示例5: drawSplashScreen
void drawSplashScreen(sf::RenderWindow & renderWindow)
{
//renderWindow.Draw(sprite::splash);
sf::String welcome;
toSFString("You are a chicken. \n The french are advancing and \nwant to fry you with lasers.\n\n Space to shoot, Z to fire shotgun",
sf::Vector2f(200, 500),
&welcome,
sf::Color(255, 0, 0));
renderWindow.Draw(welcome);
renderWindow.Display();
sf::Event event;
bool running = true;
while (running)
{
while(renderWindow.GetEvent(event))
{
if(event.Type == sf::Event::KeyPressed
|| event.Type == sf::Event::MouseButtonPressed
|| event.Type == sf::Event::Closed )
{
return;
}
}
}
}
示例6: Show
void SplashScreen::Show(sf::RenderWindow& renderWindow) {
sf::Image image;
if(image.LoadFromFile("C:\\Users\\Alex\\Documents\\Visual Studio 2010\\Projects\\PANG\\Debug\\images\\SplashScreen.png") != true)
return;
sf::Sprite sprite(image);
renderWindow.Draw(sprite);
renderWindow.Display();
sf::Event event;
sf::Clock clock;
clock.Reset();
/*while(true)
{
renderWindow.GetEvent(event);
if(event.Type == sf::Event::KeyPressed
|| event.Type == sf::Event::MouseButtonPressed
|| event.Type == sf::Event::Closed)
{
return;
}
} */
while (true) {
if (clock.GetElapsedTime() >= 2.0f)
return;
}
}
示例7: Draw
void CreditState::Draw(sf::RenderWindow &Window)
{
Window.Clear(sf::Color(250, 50, 150));
Window.Draw(mSprite);
Window.Display();
}
示例8: Draw
void ScreenMenu::Draw(sf::RenderWindow &App)
{
App.Clear();
App.Draw(backgroundSprite);
App.Draw(menuPlay);
App.Draw(menuCommandes);
App.Draw(menuQuit);
App.Display();
}
示例9: drawGraphics
void Visual::drawGraphics(sf::RenderWindow& mainWindow, World& world)
{
//mainWindow.Clear(sf::Color(50, 50, 50, 255)); //clear screen
mainWindow.Clear(sf::Color::Black);
drawWorld(mainWindow, world);
textDisplay(mainWindow);
mainWindow.Display(); //draw screen
}
示例10: main
int main(int argc, char** argv) {
initOpenGL();
loadAssets();
handleInput();
renderFrame();
while (window.IsOpened()) {
window.Display();
}
return 0;
}
示例11: Draw
void IntroState::Draw(sf::RenderWindow &Window)
{
Window.Clear();
Window.Draw(mBgSprite);
if( i < 20 )
i = 0;
else
i -= 10;
Window.Draw(sf::Shape::Rectangle(0, 0, WINWIDTH, WINHEIGHT, sf::Color(0,0,0,i)));
Window.Display();
}
示例12: Run
int Splash::Run(sf::RenderWindow &win, sf::VideoMode &vMode)
{
Event events;
while(win.IsOpened())
{
while(win.GetEvent(events))
{
if(events.Type == Event::Closed)
win.Close();
if(win.GetInput().IsKeyDown(Key::Space)) return 2;
}
if(m_scripter.RunScript(&m_splashBgImg, &m_splashBgSp) == 2) return 2;
win.Clear();
win.Draw(m_splashBgSp);
win.Display();
}
return -1;
}
示例13: 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();
}
}
}
示例14: Draw
void MenuState::Draw(sf::RenderWindow &Window)
{
Window.Clear(sf::Color(50, 50, 150));
Window.Draw(mBgSprite);
// now, we draw our menu.
for( int i = 0 ; i < mMenu.getMenuSize(); i++ )
{
if( i == mMenu.getSelectedItem() )
mMenu.isSelected(i);
else
mMenu.isNotSelected(i);
Window.Draw( mMenu.draw(i) );
}
Window.Display();
}
示例15: Show
MainMenu::MenuResult MainMenu::Show(sf::RenderWindow& window)
{
//Load menu image from file
sf::Image image;
image.LoadFromFile("images/MainScreen.png");
sf::Sprite sprite(image);
//Setup clickable regions
//Play menu item coordinates
MenuItem playButton1;
playButton1.rect.Top= 35;
playButton1.rect.Bottom =103;
playButton1.rect.Left = 35;
playButton1.rect.Right = 367;
playButton1.action = Play1;
MenuItem playButton2;
playButton2.rect.Top= 130;
playButton2.rect.Bottom = 198;
playButton2.rect.Left = 35;
playButton2.rect.Right = 367;
playButton2.action = Play2;
//Exit menu item coordinates
MenuItem helpButton;
helpButton.rect.Top = 213;
helpButton.rect.Bottom = 282;
helpButton.rect.Left = 35;
helpButton.rect.Right = 367;
helpButton.action = Help;
_menuItems.push_back(playButton1);
_menuItems.push_back(playButton2);
_menuItems.push_back(helpButton);
window.Draw(sprite);
window.Display();
return GetMenuResponse(window);
}