Class: Window
- Inherits:
- LiteRGSS::Window show all
- Defined in:
- scripts/00000 Dependencies/00001 LiteRGSS2/00003 Drawable.rb,
scripts/00700 Ajout_PSDK/01800 XXX_simple_mouse_in_.rb
Overview
Class used to show a Window object on screen.
A Window is an object that has a frame (built from #window_builder and #windowskin) and some contents that can be Sprites or Texts.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from LiteRGSS::Window
#__index__, #active, #back_opacity, #contents_opacity, #cursor_rect, #cursorskin, #height, #opacity, #ox, #oy, #pause, #pause_x, #pause_y, #pauseskin, #stretch, #viewport, #visible, #width, #window_builder, #windowskin, #x, #y, #z
Instance Method Summary collapse
-
#simple_mouse_in?(mouse_x = Mouse.x, mouse_y = Mouse.y) ⇒ Boolean
Detect if the mouse is in the window.
-
#translate_mouse_coords(mouse_x = Mouse.x, mouse_y = Mouse.y) ⇒ Array(Integer, Integer)
Convert mouse coordinate on the screen to mouse coordinates on the window.
Methods inherited from LiteRGSS::Window
#lock, #locked?, new, #set_origin, #set_position, #set_size, #unlock, #update
Methods inherited from LiteRGSS::Disposable
Instance Method Details
#simple_mouse_in?(mouse_x = Mouse.x, mouse_y = Mouse.y) ⇒ Boolean
Detect if the mouse is in the window
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'scripts/00700 Ajout_PSDK/01800 XXX_simple_mouse_in_.rb', line 121 def simple_mouse_in?(mouse_x = Mouse.x, mouse_y = Mouse.y) if return false unless .simple_mouse_in?(mouse_x, mouse_y) mouse_x, mouse_y = .translate_mouse_coords(mouse_x, mouse_y) end bx = x by = y return false if mouse_x < bx || mouse_y < by bx += width by += height return false if mouse_x >= bx || mouse_y >= by true end |
#translate_mouse_coords(mouse_x = Mouse.x, mouse_y = Mouse.y) ⇒ Array(Integer, Integer)
Convert mouse coordinate on the screen to mouse coordinates on the window
140 141 142 143 144 145 146 147 148 |
# File 'scripts/00700 Ajout_PSDK/01800 XXX_simple_mouse_in_.rb', line 140 def translate_mouse_coords(mouse_x = Mouse.x, mouse_y = Mouse.y) if mouse_x, mouse_y = .translate_mouse_coords(mouse_x, mouse_y) end rect = self.rect mouse_x -= rect.x - ox mouse_y -= rect.y - oy return mouse_x, mouse_y end |