本文整理汇总了C++中sf::RenderWindow::IsOpened方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderWindow::IsOpened方法的具体用法?C++ RenderWindow::IsOpened怎么用?C++ RenderWindow::IsOpened使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::RenderWindow
的用法示例。
在下文中一共展示了RenderWindow::IsOpened方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: main
int main(int argc, char** argv) {
initOpenGL();
loadAssets();
handleInput();
renderFrame();
while (window.IsOpened()) {
window.Display();
}
return 0;
}
示例3: 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;
}
示例4: 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();
}
}
}
示例5: spr
vector<Start_Items*> Start_Items::SetHair(sf::RenderWindow& App, sf::Sprite* menu)
{
vector<Start_Items*> parts;
int ids=0;
if (initalizeItems(ids,parts,menu) == 1) NULL;
else EXIT_FAILURE;
//cout << parts[0]->name << endl;
sf::Image img_spr;
img_spr.LoadFromFile("sprites/fig2t.png");
sf::Sprite spr(img_spr);
spr.SetPosition(200,210);
spr.Scale(1.5,1.5);
sf::Image i;
i.LoadFromFile("items/hair/next_button.jpg");
sf::Sprite next(i);
next.SetPosition(691,491);
vector<Start_Items*> eq2;
vector<Start_Items*> all;
sf::String hair_str;
hair_str.SetPosition(100,500);
while (App.IsOpened())
{
App.Clear();
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
if (Event.Type == sf::Event::MouseButtonPressed)
{
if (eq2.size() >=1 && !((Event.MouseButton.X >= 691 && Event.MouseButton.X <= 755) &&
(Event.MouseButton.Y >= 491 && Event.MouseButton.Y <=555))) eq2.clear();
for (int x=0; x<parts.size(); x++)
{
if ((Event.MouseButton.X >= parts[x]->hair.GetPosition().x && Event.MouseButton.X <= parts[x]->hair.GetPosition().x+26*(parts[x]->hair.GetScale().x)) &&
(Event.MouseButton.Y >= parts[x]->hair.GetPosition().y && Event.MouseButton.Y <= parts[x]->hair.GetPosition().y+40*(parts[x]->hair.GetScale().y)))
eq2.push_back(parts[x]);
}
if ((Event.MouseButton.X >= 691 && Event.MouseButton.X <= 755) && (Event.MouseButton.Y >= 491 && Event.MouseButton.Y <=555))
{
ids+=1;
all.push_back(eq2[0]);
if (initalizeItems(ids,parts,menu) == 2) return all;
}
}
}
//cout << ids << endl;
App.Draw(*(menu));
spr.SetSubRect(sf::IntRect(0,0,32,48));
App.Draw(spr);
if (ids>0)
{
for (int x=0; x<all.size(); x++)
{
all[x]->hair.Scale(1,1);
all[x]->hair.SetSubRect(sf::IntRect(0,0,32,48));
all[x]->hair.SetPosition(spr.GetPosition().x, spr.GetPosition().y);
App.Draw(all[x]->hair);
}
}
for (int x=0; x<eq2.size(); x++)
{
eq2[x]->hair.Scale(1,1);
eq2[x]->hair.SetSubRect(sf::IntRect(0,0,32,48));
eq2[x]->hair.SetPosition(spr.GetPosition().x, spr.GetPosition().y);
hair_str.SetText("You have selected: "+eq2[x]->name);
App.Draw(eq2[x]->hair);
App.Draw(hair_str);
}
for (int x=0; x<parts.size(); x++)
{
int wid=400+(50*(x+1));
int hei=200;
if (wid>=601)
{
hei=280;
wid=400+(50*(x-3));
}
parts[x]->hair.SetSubRect(sf::IntRect(0,0,32,47));
if (parts[x]->hair.GetScale().x != 1.5) parts[x]->hair.Scale(1.5,1.5);
parts[x]->hair.SetPosition(wid,hei);
App.Draw(parts[x]->hair);
}
App.Draw(next);
App.Display();
}
}
示例6: runAccess
//function
bool AccessOptions::runAccess(sf::RenderWindow &Menu, World& myWorld, Player& myPlayer)
{
//extern World myWorld;
//creating an image and using events
sf::Event Event;
sf::Image image;
if(!image.LoadFromFile("images/accessMenu2.png"))
return false;
//create a sprite
sf::Sprite sprite;
sprite.SetImage(image);
int xoffset = 50;
int yoffset = 25;
sprite.SetPosition(xoffset,yoffset);
//list of Buttons on screen
Button newGame = Button(305,73,Position(100+xoffset,42+yoffset));
Button saveGame = Button(193,72,Position(165+xoffset,150+yoffset));
Button resumeGame = Button(233,74,Position(144+xoffset,269+yoffset));
Button exitGame = Button(139,87,Position(195+xoffset,380+yoffset));
while(Menu.IsOpened())
{
//loop for event handling
if(Menu.GetEvent(Event))
{
if(Event.Type==sf::Event::Closed)
Menu.Close();
Position click = Position(Event.MouseButton.X, Event.MouseButton.Y);
//determining what button is pressed & task to follow
if(Event.Type==sf::Event::MouseButtonPressed && newGame.clickedOn(click))
{
sf::RenderWindow App;
startNewGame(Menu, App);
}
if(Event.Type==sf::Event::MouseButtonPressed && saveGame.clickedOn(click))
{
saveSector(myWorld,myPlayer);
}
if(Event.Type==sf::Event::MouseButtonPressed && resumeGame.clickedOn(click))
{
return true;
}
if(Event.Type==sf::Event::MouseButtonPressed &&exitGame.clickedOn(click))
{
//also closes all other windows and system
return false;
}
}
//clear window
//Menu.Clear();
//draw sprite
Menu.Draw(sprite);
//display
Menu.Display();
}
return true;
}