class Gosu::Window
- Gosu::Window
- Reference
- Object
Defined in:
gosu/window.crConstructors
Instance Method Summary
-
#button_down(id : UInt32)
This method is called before
#update
if a button is pressed while the window has focus. -
#button_up(id : UInt32)
This method is called before
#update
if a button is released while the window has focus. -
#caption : String
Returns the window's caption, usually displayed in the title bar.
-
#caption=(string : String)
Sets the window's caption to
string
. -
#close : Bool
This method is called whenever the user tries to close the window, e.g.
-
#close! : Bool
Tells the window to end the current run loop as soon as possible.
-
#draw
This method is called after every update and whenever the OS wants the window to repaint itself.
-
#drop(filename : String)
Called when a file is dropped onto the window.
-
#fullscreen=(boolean : Bool)
Sets whether window is fullscreen to
boolean
. -
#fullscreen? : Bool
Returns whether this is a fullscreen window.
- #gain_focus
- #gamepad_connected(id : UInt32)
- #gamepad_disconnected(id : UInt32)
-
#height : Int32
The window's height, in pixels.
-
#height=(int : Int32)
Sets the window's height to
int
. - #lose_focus
-
#mouse_x : Float64
Returns the mouse pointer's window-based X coordinate.
-
#mouse_x=(double : Float64)
Sets the mouse pointer's X coordinate to
double
. -
#mouse_y : Float64
Returns the mouse pointer's window-based Y coordinate.
-
#mouse_y=(double : Float64)
Sets the mouse pointer's Y coordinate to
double
. -
#needs_cursor? : Bool
This method can be overriden to control the visibility of the system cursor over your window, e.g., for level editors or other situations where introducing a custom cursor or hiding the default one is not desired.
-
#needs_redraw? : Bool
This method can be overriden to give the game a chance to opt out of a call to
#draw
; however, the operating system can still force a redraw for any reason. -
#resizable? : Bool
Whether this window is resizable.
- #resize(width : Int32, height : Int32, fullscreen : Bool)
-
#show
Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc.
-
#text_input : Gosu::TextInput | Nil
The currently active
TextInput
. -
#text_input=(input : Gosu::TextInput | Nil)
Sets the active
TextInput
toinput
. -
#tick : Bool
EXPERIMENTAL - MAY DISAPPEAR WITHOUT WARNING.
-
#update
This method is called once every
#update_interval
milliseconds while the window is being shown. -
#update_interval : Float64
Returns the interval between calls to
#update
, in milliseconds. -
#update_interval=(double : Float64)
Sets the interval between calls to
#update
. -
#width : Int32
The window's width, in pixels.
-
#width=(int : Int32)
Sets the window's width to
int
.
Constructor Detail
Instance Method Detail
This method is called before #update
if a button is pressed while the window has 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 super in your implementation.
id
the button's platform-defined id.
See #button_up
See Gosu.button_down?
This method is called before #update
if a button is released while the window has focus.
id
the button's platform-defined id.
See #button_down
See button_down?
This method is called whenever the user tries to close the window, e.g. by clicking the [x]
button in the window's title bar.
If you do not want the window to close immediately, you should override this method and
call the #close!
when needed.
This method is called after every update and whenever the OS wants the window to repaint itself. Your application's rendering code should go here.
See #needs_redraw?
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.
The window's height, in pixels. This only counts the drawable area and does not include any borders or decorations added by the window manager.
This method can be overriden to control the visibility of the system cursor over your window, e.g., for level editors or other situations where introducing a custom cursor or hiding the default one is not desired.
Returns whether the system cursor should be shown.
This method can be overriden to give the game a chance to opt out of a call to #draw
; however, the operating system can still force a redraw for any reason.
Returns whether the window needs to be redrawn.
See #draw
Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc.
The currently active TextInput
. If not nil, all keyboard input will be handled by this object.
Returns the currently active text input, if any.
Sets the active TextInput
to input
. Set to nil to disable keyboard capture.
EXPERIMENTAL - MAY DISAPPEAR WITHOUT WARNING.
Performs a single step in the main loop. This can be useful for integrating Gosu with other libraries that have their own main loop, e.g. Ruby/Tk.
See: https://www.libgosu.org/cgi-bin/mwf/topic_show.pl?tid=1218
If you find a good way to use #tick
, please let us know on the forum and we can make this a part of Gosu's stable interface.
Thank you!
This method is called once every #update_interval
milliseconds while the window is being shown. Your application's main logic should go here.
The window's width, in pixels. This only counts the drawable area and does not include any borders or decorations added by the window manager.