Game Development Reference
In-Depth Information
Take a look at this example where a string is assembled out of characters using the Tex-
tEntered event and, when the Enter (or Return ) button is pressed, the text is set as the
title:
Note that the string buffer that we are using is of type sf::String and not
std::string . The sf::String class is created to automatically handle conversion
between string types and encodings. As such, we do not have to worry about the language
or symbols on a keyboard layout—it can store any character from any language.
To finish off event handling, it is important to mention that there is an alternative to how
events are pulled from the window. Apart from using Window::pollEvent() , we can
also use bool Window::waitEvent(Event& event) , which blocks the thread
until an event is received. It only returns false when something wrong occurs inside (an
error or exception of some sort), otherwise it always returns true . This can be useful
Search WWH ::




Custom Search