Class: Text

Inherits:
LiteRGSS::Text show all
Defined in:
scripts/00000 Dependencies/00001 LiteRGSS2/00003 Drawable.rb,
scripts/00700 Ajout_PSDK/01800 XXX_simple_mouse_in_.rb

Overview

Class that describes a text shown on the screen or inside a viewport

Direct Known Subclasses

Sprite_Timer, UI::SymText, UI::UserInput

Instance Attribute Summary

Attributes inherited from LiteRGSS::Text

#__index__, #align, #bold, #draw_shadow, #fill_color, #height, #italic, #nchar_draw, #opacity, #outline_color, #outline_thickness, #real_width, #size, #text, #viewport, #visible, #width, #x, #y, #z

Instance Method Summary collapse

Methods inherited from LiteRGSS::Text

#load_color, #multiline_text=, new, #set_position, #text_width

Methods inherited from LiteRGSS::Disposable

#dispose, #disposed?

Instance Method Details

#simple_mouse_in?(mouse_x = Mouse.x, mouse_y = Mouse.y) ⇒ Boolean

Detect if the mouse is in the sprite (without rotation and stuff like that)

Parameters:

  • mouse_x (Integer) (defaults to: Mouse.x)

    the mouse x position on the screen

  • mouse_y (Integer) (defaults to: Mouse.y)

    the mouse y position on the screen

Returns:

  • (Boolean)

Author:

  • Nuri Yuri



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'scripts/00700 Ajout_PSDK/01800 XXX_simple_mouse_in_.rb', line 62

def simple_mouse_in?(mouse_x = Mouse.x, mouse_y = Mouse.y)
  if viewport
    return false unless viewport.simple_mouse_in?(mouse_x, mouse_y)
    mouse_x, mouse_y = viewport.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 sprite

Parameters:

  • mouse_x (Integer) (defaults to: Mouse.x)

    the mouse x position on the screen

  • mouse_y (Integer) (defaults to: Mouse.y)

    the mouse y position on the screen

Returns:

Author:

  • Nuri Yuri



81
82
83
84
85
86
# File 'scripts/00700 Ajout_PSDK/01800 XXX_simple_mouse_in_.rb', line 81

def translate_mouse_coords(mouse_x = Mouse.x, mouse_y = Mouse.y)
  mouse_x, mouse_y = viewport.translate_mouse_coords(mouse_x, mouse_y) if viewport
  mouse_x -= x
  mouse_y -= y
  return mouse_x, mouse_y
end