| Class | Rubygame::Screen |
| In: |
ext/rubygame/rubygame_transform.c
|
| Parent: | cSurface |
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, we 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 and the Draw functions. However, the Screen cannot have a colorkey or an alpha channel, so Surface#set_colorkey and Surface#set_alpha are not inherited.
Please note that only one Screen can exist, per application, at a time; this is a limitation of SDL. You must use Screen.set_mode to create the Screen or modify its properties.
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.
Returns the current display window, or raises SDLError if it fails to get it (for example, if it doesn‘t exist yet).
A dummy function which will raise StandardError! You must instead use Screen.set_mode() to create or change the Screen mode!
Screen is a Singleton-style class, which means that only one may exist at a time (per application). You can create a Screen or change the existing one using Screen.set_mode, and get a reference to an existing Screen with Screen.get_surface
A Screen.new method would imply that more than one could be created, so to avoid confusion Screen has no such method.
(But, this annoying behavior feels like a really bad wart, so in the future, Screen.new will probably be an alias to set_mode. Let me know what you think about this.)
Create a new Rubygame window if there is none, or modify the existing one. Returns the resulting Surface.
This method takes these arguments:
| 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).
|
Returns the current window title and icon caption for the Screen as an Array. See set_caption for a description of the window title/icon caption. By default, the title and icon caption are empty strings.
Sets the window title and icon caption for the Screen.
This method takes these arguments:
| title: | a String, (usually) displayed at the top of the Rubygame window (when not in fullscreen mode). If omitted or nil, title will be an empty string. How this string is displayed (if at all) is system-dependent. |
| icon_cap: | a String, (usually) displayed when the window is iconized (minimized), for example to the taskbar. If omitted on nil, icon_cap will be the same as title. How this string is displayed (if at all) is system-dependent. |
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 Display.set_mode), you should use Screen#flip instead.
This method takes these arguments:
| 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.
This method takes these arguments:
| rects: | an Array containing any number of Rect objects, each rect representing a portion of the screen to update. |