本文整理汇总了C++中sf::RenderWindow::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderWindow::Clear方法的具体用法?C++ RenderWindow::Clear怎么用?C++ RenderWindow::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::RenderWindow
的用法示例。
在下文中一共展示了RenderWindow::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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;
}
}
}
示例3: Draw
void CreditState::Draw(sf::RenderWindow &Window)
{
Window.Clear(sf::Color(250, 50, 150));
Window.Draw(mSprite);
Window.Display();
}
示例4: playDeath
bool Player::playDeath(sf::RenderWindow& window)
{
window.Clear();
bool result = death.Update(window.GetFrameTime());
window.Draw(death_sprite);
return result;
}
示例5: Draw
void ScreenMenu::Draw(sf::RenderWindow &App)
{
App.Clear();
App.Draw(backgroundSprite);
App.Draw(menuPlay);
App.Draw(menuCommandes);
App.Draw(menuQuit);
App.Display();
}
示例6: 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
}
示例7:
void GUI::Menu::Menu::draw(sf::RenderWindow& window) {
// 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(320, 240);
window.SetView(view);
window.Clear(sf::Color(0xcc, 0x66, 0x33));
Container::draw(window);
window.Draw(logoSprite);
}
示例8: 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();
}
示例9: Show
void SplashScreen::Show(sf::RenderWindow& renderWindow)
{
sf::Image image;
sf::Color bgColor = sf::Color(40,40,40);
//Replace this?
if (image.LoadFromFile("test.png") != true)
return;
sf::Sprite sprite(image);
cerr<<renderWindow.GetWidth()/2<<" "<< renderWindow.GetHeight()/2<<endl;
sprite.SetCenter(184/2,184/2);
sprite.SetPosition(renderWindow.GetWidth()/2 , renderWindow.GetHeight()/2);
renderWindow.Clear(bgColor);
renderWindow.Draw(sprite);
renderWindow.Display();
sf::Event event;
sf::Clock clock;
while(clock.GetElapsedTime()<3)
{
while(renderWindow.GetEvent(event))
{
if ( event.Type == sf::Event::KeyPressed
|| event.Type == sf::Event::MouseButtonPressed
|| event.Type == sf::Event::Closed)
{
renderWindow.Clear(bgColor);
return;
}
}
}
renderWindow.Clear(bgColor);
return;
}
示例10: 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;
}
示例11: 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();
}
}
}
示例12: 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();
}
示例13: Show
void SplashScreen::Show(sf::RenderWindow & renderWindow)
{
renderWindow.Clear();
renderWindow.Draw(mySprBack);
renderWindow.Display();
sf::Event event;
//on sort pour faire plus vite
while(false)
{
while(renderWindow.PollEvent(event))
{
if(event.Type == sf::Event::KeyPressed
|| event.Type == sf::Event::MouseButtonPressed
|| event.Type == sf::Event::Closed
|| event.Type == sf::Event::JoystickButtonPressed)
{
return;
}
}
}
}
示例14: draw
void GameScreen::draw (sf::RenderWindow &app)
{
app.Clear();
app.SetView(ConfigOptions::getView()); //switching to custom view for easy resizing of the screen
app.Draw(m_background);
m_highlighter.draw(app);
if(m_selectedPiece != NULL_SQUARE)
app.Draw(m_selectionSprite);
if(m_selectedTarget != NULL_SQUARE)
app.Draw(m_targettingSprite);
app.Draw(m_cursor);
for(std::map<PiecePtr, PieceSprite>::iterator it = m_pieces.begin(); it != m_pieces.end(); ++it)
app.Draw(it->second);
if(!isOver())
{
if(m_game.getActivePlayer() == GOLD)
app.Draw(m_goldTurnIndicator);
else //SILVER
app.Draw(m_silverTurnIndicator);
if(m_game.hasStarted())
{
app.Draw(m_movesBackgroundSprite);
app.Draw(m_nbMovesSprite);
}
else //game has not started
{
m_placementUI.draw(app, m_game.canEndPlacement());
}
m_turnSign.draw(app);
}
else //the game is over
app.Draw(m_victorySign);
app.SetView(app.GetDefaultView()); //switching back to default view
app.Display();
}
示例15: Show
void SplashScreen::Show(sf::RenderWindow& window)
{
window.Clear(sf::Color(0,0,0));
sf::Image image;
if(image.LoadFromFile("assets/paint-wars.png") !=true)
{
return;
}
sf::Sprite sprite(image);
window.Draw(sprite);
sf::String inst = sf::String("Press any key or click the mouse to continue.");
inst.SetPosition(
Game::SCREEN_WIDTH / 2 - 300,
Game::SCREEN_HEIGHT / 2
);
window.Draw(inst);
window.Display();
sf::Event event;
while(true)
{
while(window.GetEvent(event))
{
if(event.Type == sf::Event::KeyPressed ||
event.Type == sf::Event::MouseButtonPressed ||
event.Type == sf::Event::Closed)
{
return;
}
}
}
}