Class | Rubygame::Screen |
In: |
lib/rubygame/screen.rb
lib/rubygame/screen.rb |
Parent: | Rubygame::Surface |
Screen represents the display window for the game. The Screen is a special Surface that is displayed to the user. By changing and then updating the Screen many times per second, you can create the illusion of continous motion.
Screen inherits most of the Surface methods, and can be passed to methods which expect a Surface, including Surface#blit. However, the Screen cannot have an alpha channel or a colorkey, so Surface#alpha=, Surface#set_alpha, Surface#colorkey=, and Surface#set_colorkey are not inherited.
Please note that only one Screen can exist at a time, per application; this is a limitation of SDL. Use Screen.new (or its alias, Screen.open) to create or modify the Screen.
Also note that no changes to the Screen will be seen until it is refreshed. See update, update_rects, and flip for ways to refresh all or part of the Screen.
new | -> | open |
new | -> | open |
Close the Screen, making the Rubygame window disappear. This method also exits from fullscreen mode, if needed.
After calling this method, you should discard any references to the old Screen surface, as it is no longer valid, even if you call Screen.new again.
(Note: You do not need to close the Screen to change its size or flags, you can simply call Screen.new while already open.)
Close the Screen, making the Rubygame window disappear. This method also exits from fullscreen mode, if needed.
After calling this method, you should discard any references to the old Screen surface, as it is no longer valid, even if you call Screen.new again.
(Note: You do not need to close the Screen to change its size or flags, you can simply call Screen.new while already open.)
Returns the pixel dimensions of the user‘s display (i.e. monitor). (That is not the same as Screen#size, which only measures the Rubygame window.) You can use this information to detect how large of a Screen can fit on the user‘s display.
This method can only be used when there is no open Screen instance. This method raises SDLError if there is a Screen instance (i.e. you have done Screen.new before). This is a limitation of the SDL function SDL_GetVideoInfo, which behaves differently when a Screen is open than when it is closed.
This method will also raise SDLError if it cannot get the display size for some other reason.
Returns the pixel dimensions of the user‘s display (i.e. monitor). (That is not the same as Screen#size, which only measures the Rubygame window.) You can use this information to detect how large of a Screen can fit on the user‘s display.
This method can only be used when there is no open Screen instance. This method raises SDLError if there is a Screen instance (i.e. you have done Screen.new before). This is a limitation of the SDL function SDL_GetVideoInfo, which behaves differently when a Screen is open than when it is closed.
This method will also raise SDLError if it cannot get the display size for some other reason.
Deprecated alias for Screen.new. This method will be REMOVED in Rubygame 3.0. You should use Screen.new (or its alias, Screen.open) instead.
Deprecated alias for Screen.new. This method will be REMOVED in Rubygame 3.0. You should use Screen.new (or its alias, Screen.open) instead.
Create a new Rubygame window if there is none, or modify the existing one. You cannot create more than one Screen; the existing one will be replaced. (This is a limitation of SDL.)
Returns the resulting Screen.
size: | requested window size (in pixels), in the form [width,height] | ||||||||||||||||||
depth: | requested color depth (in bits per pixel). If 0 (default), the current system color depth. | ||||||||||||||||||
flags: | an Array of zero or more of the following flags (located under the Rubygame module).
|
Create a new Rubygame window if there is none, or modify the existing one. You cannot create more than one Screen; the existing one will be replaced. (This is a limitation of SDL.)
Returns the resulting Screen.
size: | requested window size (in pixels), in the form [width,height] | ||||||||||||||||||
depth: | requested color depth (in bits per pixel). If 0 (default), the current system color depth. | ||||||||||||||||||
flags: | an Array of zero or more of the following flags (located under the Rubygame module).
|
Deprecated alias for Screen.new. This method will be REMOVED in Rubygame 3.0. You should use Screen.new (or its alias, Screen.open) instead.
Deprecated alias for Screen.new. This method will be REMOVED in Rubygame 3.0. You should use Screen.new (or its alias, Screen.open) instead.
If the Rubygame display is double-buffered (see Screen.new), flips the buffers and updates the whole screen. Otherwise, just updates the whole screen.
If the Rubygame display is double-buffered (see Screen.new), flips the buffers and updates the whole screen. Otherwise, just updates the whole screen.
Sets the window icon for the Screen.
icon: | a Rubygame::Surface to be displayed at the top of the Rubygame window (when not in fullscreen mode), and in other OS-specific areas (like the taskbar entry). If omitted or nil, no icon will be shown at all. |
NOTE: The SDL docs state that icons on Win32 systems must be 32x32 pixels. That may or may not be true anymore, but you might want to consider it when creating games to run on Windows.
Sets the window icon for the Screen.
icon: | a Rubygame::Surface to be displayed at the top of the Rubygame window (when not in fullscreen mode), and in other OS-specific areas (like the taskbar entry). If omitted or nil, no icon will be shown at all. |
NOTE: The SDL docs state that icons on Win32 systems must be 32x32 pixels. That may or may not be true anymore, but you might want to consider it when creating games to run on Windows.
Set whether the mouse cursor is displayed or not. If value is true, the cursor will be shown; if false, it will be hidden. See also show_cursor?
Set whether the mouse cursor is displayed or not. If value is true, the cursor will be shown; if false, it will be hidden. See also show_cursor?
Updates (refreshes) all or part of the Rubygame window, revealing to the user any changes that have been made since the last update. If you‘re using a double-buffered display (see Screen.new), you should use Screen#flip instead.
rect: | a Rubygame::Rect representing the area of the screen to update. Can also be an length-4 Array, or given as 4 separate arguments. If omitted or nil, the entire screen is updated. |
Updates (refreshes) all or part of the Rubygame window, revealing to the user any changes that have been made since the last update. If you‘re using a double-buffered display (see Screen.new), you should use Screen#flip instead.
rect: | a Rubygame::Rect representing the area of the screen to update. Can also be an length-4 Array, or given as 4 separate arguments. If omitted or nil, the entire screen is updated. |
Updates (as Screen#update does) several areas of the screen.
rects: | an Array containing any number of Rect objects, each rect representing a portion of the screen to update. |
Updates (as Screen#update does) several areas of the screen.
rects: | an Array containing any number of Rect objects, each rect representing a portion of the screen to update. |