本文整理汇总了C++中sf::RenderWindow::GetDefaultView方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderWindow::GetDefaultView方法的具体用法?C++ RenderWindow::GetDefaultView怎么用?C++ RenderWindow::GetDefaultView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::RenderWindow
的用法示例。
在下文中一共展示了RenderWindow::GetDefaultView方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
示例2:
void ObjBackground::draw(sf::RenderWindow& window)
{
// _sprite loop qui se termine
window.SetView(window.GetDefaultView());
const sf::Vector2f position = _sprite.GetPosition();
window.Draw(_sprite);
for (unsigned int i = 0; i < 20; ++i)
{
_sprite.SetPosition(position.x + (_image->GetWidth() * i), position.y);
window.Draw(_sprite);
}
_sprite.SetPosition(position);
window.SetView(GGJ::Context::getSingleton().accessView());
}
示例3: 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();
}
}
}
示例4: 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();
}
示例5:
gra_screen::gra_screen(sf::RenderWindow &App,sf::Font & font)
{
osttime=0;
korektatime=0;
zam=false;
WspolTarciaGracz=0;
WspolTarciaPilka=0;
dan=0;
pozres=false;
lingran=0;
pilka=0;
slupek=0;
gracz1_im=0;
gracz2_im=0;
gracz=0;
boisko_im=0;
wynl=0;
wynp=0;
bg=100;
bd=500;
bl=100;
bp=700;
bramka=100;
gracze_ob=0;
gracze_ev=0;
obiekty=0;
loaded=false;
view=App.GetDefaultView();
events=new EventComp;
(*events).Set(sf::Event::KeyPressed,sf::Key::Escape);
wynik_obl.SetFont(font);
//wynik_obs.SetFont(font);
wynik_obp.SetFont(font);
Timer_ob1.SetFont(font);
//Timer_ob2.SetFont(font);
wynik_obl.SetSize(80);
//wynik_obs.SetSize(80);
wynik_obp.SetSize(80);
wynik_obl.SetStyle(sf::String::Bold);
//wynik_obs.SetStyle(sf::String::Bold);
wynik_obp.SetStyle(sf::String::Bold);
wynik_obl.SetText("0");
//wynik_obs.SetText(":");
wynik_obp.SetText("0");
wynik_obl.SetPosition(App.GetWidth()/4,wynik_obl.GetRect().GetHeight()/2);
//wynik_obs.SetPosition(App.GetWidth()/2-wynik_obs.GetRect().GetWidth()/2,0);
wynik_obp.SetPosition(App.GetWidth()*3/4,wynik_obp.GetRect().GetHeight()/2);
wynik_obl.SetColor(sf::Color(30,30,250));
//wynik_obs.SetColor(sf::Color(250,30,30));
wynik_obp.SetColor(sf::Color(30,250,30));
wynik_obl.SetCenter(wynik_obl.GetRect().GetWidth()/2,wynik_obl.GetRect().GetHeight()/2);
wynik_obp.SetCenter(wynik_obp.GetRect().GetWidth()/2,wynik_obp.GetRect().GetHeight()/2);
Timer_ob1.SetSize(60);
//Timer_ob2.SetSize(60);
Timer_ob1.SetStyle(sf::String::Bold);
//Timer_ob2.SetStyle(sf::String::Bold);
Timer_ob1.SetText("00:00");
//Timer_ob2.SetText("00:00");
Timer_ob1.SetPosition(App.GetWidth()/2,wynik_obl.GetRect().GetHeight()/2); // wynik_obl zastosowany umyslnie. aby byly wzglednie wysrodkowane.
Timer_ob1.SetCenter(Timer_ob1.GetRect().GetWidth()/2,Timer_ob1.GetRect().GetHeight()/2);
//Timer_ob2.SetPosition(App.GetWidth()-Timer_ob2.GetRect().GetWidth(),0);
Techdata.SetPosition(10,App.GetHeight()-40);
}