SFML и C++ Уроки \ Разработка игр › Форумы › SFML System, Window и другие вопросы › SF::Text › Ответ в теме: SF::Text
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
#include <SFML/Graphics.hpp> #include <SFML/System.hpp> using namespace sf; int main() { VideoMode videoMode(320, 240); RenderWindow window(videoMode, "KeyEvent and text Window"); //create some text Text text("SFML text"); //create rect shape RectangleShape rectangle; rectangle.setPosition(30,30); rectangle.setSize(Vector2f(50,30)); //set rect's properties rectangle.setFillColor(Color::Yellow); rectangle.setOutlineColor(Color::Blue); rectangle.setOutlineThickness(3); while (window.isOpen()) { window.clear(); window.draw(text); //window.draw(rectangle); window.display(); Event event; while(window.pollEvent(event)) { if( (event.type == Event::Closed) || (event.type == Event::KeyPressed) && (event.key.code==Keyboard::Escape) ) //allows to close the window by using close button on the title bar of the window (or by pressing ESC), also allows using two other buttons of the title bar. window.close(); /*else { if (event.type == Event::KeyPressed) { switch(event.key.code) { case Keyboard::Up: rectangle.move(0,-10); break; case Keyboard::Down: rectangle.move(0,10); break; case Keyboard::Left: rectangle.move(-10,0); break; case Keyboard::Right: rectangle.move(10,0); break; } } }*/ } } //system("PAUSE"); return EXIT_SUCCESS; } |