SFML community forums
Help => Window => Topic started by: Dima00782@yandex.ru on December 04, 2013, 02:09:58 pm
-
Hello everybody.
I want to implement this behavior:
The user initially sees the main application window - menu, this menu has items - "options", "load", "save", "play."
I want to switch to another view when click on "play". How do I do this?
-
This is done by having multiple surfaces, often called "states", such as main menu, options, game.
One possibility is to have an abstract base class State and derived classes MainMenu, Options, Game for a concrete state. When clicking a button, the state is changed (either by creating a new state object and possibly destroying the old one, or just changing a pointer).
-
Thanks for the answer.
From the point of view of patterns it is clear but how to make it in sfml? What classes to use, right there is no JPanel or JFrame as in Swing.
-
There are no GUI classes in SFML. You can either build your own around the basic drawables (sf::Text, sf::Sprite, sf::Shape), or use an existing GUI extension such as SFGUI or TGUI.