class Gosu::Window

Defined in:

gosu/window.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(width, height, fullscreen = false, update_interval = 16.66666667, resizable = false, borderless = false) #

[View source]

Instance Method Detail

def button_down(id : UInt32) #

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?


[View source]
def button_up(id : UInt32) #

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?


[View source]
def caption : String #

Returns the window's caption, usually displayed in the title bar.


[View source]
def caption=(string : String) #

Sets the window's caption to string.


[View source]
def close : Bool #

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.


[View source]
def close! : Bool #

Tells the window to end the current run loop as soon as possible.


[View source]
def draw #

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?


[View source]
def drop(filename : String) #

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.


[View source]
def fullscreen=(boolean : Bool) #

Sets whether window is fullscreen to boolean.


[View source]
def fullscreen? : Bool #

Returns whether this is a fullscreen window.


[View source]
def gain_focus #

[View source]
def gamepad_connected(id : UInt32) #

[View source]
def gamepad_disconnected(id : UInt32) #

[View source]
def height : Int32 #

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.


[View source]
def height=(int : Int32) #

Sets the window's height to int.


[View source]
def lose_focus #

[View source]
def mouse_x : Float64 #

Returns the mouse pointer's window-based X coordinate.


[View source]
def mouse_x=(double : Float64) #

Sets the mouse pointer's X coordinate to double.


[View source]
def mouse_y : Float64 #

Returns the mouse pointer's window-based Y coordinate.


[View source]
def mouse_y=(double : Float64) #

Sets the mouse pointer's Y coordinate to double.


[View source]
def 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.

Returns whether the system cursor should be shown.


[View source]
def 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.

Returns whether the window needs to be redrawn.

See #draw


[View source]
def resizable? : Bool #

Whether this window is resizable.


[View source]
def resize(width : Int32, height : Int32, fullscreen : Bool) #

Sets window's #width, #height and whether window is fullscreen.


[View source]
def show #

Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc.


[View source]
def text_input : Gosu::TextInput | Nil #

The currently active TextInput. If not nil, all keyboard input will be handled by this object.

Returns the currently active text input, if any.


[View source]
def text_input=(input : Gosu::TextInput | Nil) #

Sets the active TextInput to input. Set to nil to disable keyboard capture.


[View source]
def tick : Bool #

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!


[View source]
def update #

This method is called once every #update_interval milliseconds while the window is being shown. Your application's main logic should go here.


[View source]
def update_interval : Float64 #

Returns the interval between calls to #update, in milliseconds.


[View source]
def update_interval=(double : Float64) #

Sets the interval between calls to #update.


[View source]
def width : Int32 #

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.


[View source]
def width=(int : Int32) #

Sets the window's width to int.


[View source]