Gosu
|
Convenient all-in-one class that serves as the foundation of a standard Gosu application. More...
Public Member Functions | |
Window (unsigned width, unsigned height, bool fullscreen=false, double update_interval=16.666666, bool resizable=false) | |
Constructs a Window. More... | |
virtual | ~Window () |
unsigned | width () const |
unsigned | height () const |
bool | fullscreen () const |
bool | resizable () const |
void | resize (unsigned width, unsigned height, bool fullscreen) |
double | update_interval () const |
void | set_update_interval (double update_interval) |
std::string | caption () const |
void | set_caption (const std::string &caption) |
virtual void | show () |
Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc. More... | |
virtual bool | tick () |
EXPERIMENTAL - MAY DISAPPEAR WITHOUT WARNING. More... | |
virtual void | close () |
Closes the window if it is currently shown. More... | |
virtual void | update () |
Called every update_interval milliseconds while the window is being shown. More... | |
virtual void | draw () |
Called after every update and when the OS wants the window to repaint itself. More... | |
virtual bool | needs_redraw () const |
Gives the game a chance to say no to being redrawn. More... | |
virtual bool | needs_cursor () const |
If this function returns true, the system cursor will be visible while over the window. More... | |
virtual void | lose_focus () |
This function is called when the window loses focus on some platforms. More... | |
virtual void | release_memory () |
This function is called when the operating system's memory is low. More... | |
virtual void | button_down (Gosu::Button) |
Called before update when the user presses a button while the window has the focus. More... | |
virtual void | button_up (Gosu::Button) |
Same as button_down. Called when the user releases a button. More... | |
virtual void | gamepad_connected (int index) |
Called when a gamepad is connected. More... | |
virtual void | gamepad_disconnected (int index) |
Called when a gamepad is disconnected. More... | |
virtual void | drop (const std::string &filename) |
Called when a file is dropped onto the window. More... | |
virtual void | touch_began (Touch touch) |
virtual void | touch_moved (Touch touch) |
virtual void | touch_ended (Touch touch) |
virtual void | touch_cancelled (Touch touch) |
const Graphics & | graphics () const |
Graphics & | graphics () |
const Input & | input () const |
Input & | input () |
Convenient all-in-one class that serves as the foundation of a standard Gosu application.
Manages initialization of all of Gosu's core components and provides timing functionality. Note that you should really only use one instance of this class at the same time.
Definition at line 14 of file Window.hpp.
Gosu::Window::Window | ( | unsigned | width, |
unsigned | height, | ||
bool | fullscreen = false , |
||
double | update_interval = 16.666666 , |
||
bool | resizable = false |
||
) |
Constructs a Window.
width | Width of the window in points; that is, pixels on a normal display, and 'points' on a high-resolution display. |
height | See width. |
update_interval | Interval in milliseconds between two calls to the update member function. |
|
virtual |
|
virtual |
Called before update when the user presses a button while the window has the focus.
By default, this will toggle fullscreen mode if the user presses Alt+Enter (Windows, Linux), cmd+F (macOS), or F11 (on all operating systems). To support these shortcuts in your application, make sure to call Window::button_down in your implementation.
Referenced by release_memory().
|
virtual |
Same as button_down. Called when the user releases a button.
Definition at line 94 of file Window.hpp.
std::string Gosu::Window::caption | ( | ) | const |
|
virtual |
Closes the window if it is currently shown.
If you do not want the window to close immediately, you should override this method and only call the base implementation (Window::close) when needed.
|
virtual |
Called after every update and when the OS wants the window to repaint itself.
Your application's rendering code goes here.
Definition at line 67 of file Window.hpp.
|
virtual |
Called when a file is dropped onto the window.
filename | The filename of the dropped file. When multiple files are dropped, this method will be called several times. |
Definition at line 107 of file Window.hpp.
bool Gosu::Window::fullscreen | ( | ) | const |
|
virtual |
Called when a gamepad is connected.
index | the index of the gamepad slot that the gamepad is in. |
Definition at line 98 of file Window.hpp.
|
virtual |
Called when a gamepad is disconnected.
index | the index of the gamepad slot that the gamepad is in. The slot will be freed immediately after this callback. |
Definition at line 102 of file Window.hpp.
const Graphics& Gosu::Window::graphics | ( | ) | const |
Referenced by touch_cancelled().
Graphics& Gosu::Window::graphics | ( | ) |
unsigned Gosu::Window::height | ( | ) | const |
const Input& Gosu::Window::input | ( | ) | const |
Referenced by touch_cancelled().
Input& Gosu::Window::input | ( | ) |
|
virtual |
This function is called when the window loses focus on some platforms.
Most importantly, it is called on the iPhone or iPad when the user locks the screen.
Definition at line 80 of file Window.hpp.
|
virtual |
If this function returns true, the system cursor will be visible while over the window.
Definition at line 76 of file Window.hpp.
|
virtual |
Gives the game a chance to say no to being redrawn.
This is not a definitive answer. The operating system can still force the window to redraw itself. By default, the window is redrawn all the time.
Definition at line 73 of file Window.hpp.
|
virtual |
This function is called when the operating system's memory is low.
So far, it is only called in iOS applications.
Definition at line 84 of file Window.hpp.
References button_down().
bool Gosu::Window::resizable | ( | ) | const |
void Gosu::Window::resize | ( | unsigned | width, |
unsigned | height, | ||
bool | fullscreen | ||
) |
void Gosu::Window::set_caption | ( | const std::string & | caption | ) |
void Gosu::Window::set_update_interval | ( | double | update_interval | ) |
|
virtual |
Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc.
|
virtual |
EXPERIMENTAL - MAY DISAPPEAR WITHOUT WARNING.
Performs a single main loop step. This method is only useful if you want to integrate Gosu with another library that has its own main loop. This method implicitly shows the window if it was hidden before, and returns false when the window has been closed. If you discard the return value and keep calling tick(), the window will be shown again, or keep being shown.
|
virtual |
Definition at line 112 of file Window.hpp.
|
virtual |
Definition at line 115 of file Window.hpp.
References Gosu::available_height(), Gosu::available_width(), graphics(), input(), Gosu::screen_height(), and Gosu::screen_width().
|
virtual |
Definition at line 114 of file Window.hpp.
|
virtual |
Definition at line 113 of file Window.hpp.
|
virtual |
Called every update_interval milliseconds while the window is being shown.
Your application's main game logic goes here.
Definition at line 63 of file Window.hpp.
double Gosu::Window::update_interval | ( | ) | const |
unsigned Gosu::Window::width | ( | ) | const |