Class: Sprite
- Inherits:
- LiteRGSS::ShaderedSprite 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 describe a sprite shown on the screen or inside a viewport
Direct Known Subclasses
BattleUI::TargetSelection::Button::Background, BattleUI::TrainerPartyBalls::BallSprite, NuriYuri::DynamicLight::DynamicLightSprite, Plane, RPG::Sprite, ShaderedSprite, WithColor, UI::Bag::Arrow, UI::Casino::BandDisplay, UI::Hall_of_Fame::Turning_Pokeball, UI::HoldSprite, UI::ItemSprite, UI::JKeyBinding, UI::KeyShortcut, UI::MiningGame::Background, UI::Options::Arrow, UI::PokemonFaceSprite, UI::PokemonFootSprite, UI::Quest::Arrow, UI::Quest::QuestFrame, UI::RealHoldSprite, UI::Shop::ShopBanner, UI::VoltorbFlip::Cursor, UI::VoltorbFlip::MemoTile
Defined Under Namespace
Classes: WithColor
Instance Attribute Summary
Attributes inherited from LiteRGSS::ShaderedSprite
Attributes inherited from LiteRGSS::Sprite
#__index__, #angle, #bitmap, #height, #mirror, #opacity, #ox, #oy, #src_rect, #viewport, #visible, #width, #x, #y, #z, #zoom, #zoom_x, #zoom_y
Instance Method Summary collapse
-
#load(texture, cache = nil, auto_rect = false) ⇒ self
(also: #set_bitmap)
Set the texture show on the screen surface.
-
#mouse_in?(mouse_x = Mouse.x, mouse_y = Mouse.y) ⇒ Boolean
Detect if the mouse is in the sprite (without rotation).
-
#set_origin_div(ox, oy) ⇒ self
define the pixel of the bitmap that is shown at the coordinate of the sprite.
-
#set_rect(x, y, width, height) ⇒ self
Define the surface of the bitmap that is shown on the screen surface.
-
#set_rect_div(x, y, width, height) ⇒ self
Define the surface of the bitmap that is shown with division of it.
-
#set_z(z) ⇒ self
define the superiority of the sprite.
-
#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).
-
#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.
-
#update
RGSS Compatibility “update” the sprite.
Methods inherited from LiteRGSS::Sprite
new, #set_origin, #set_position
Methods inherited from LiteRGSS::Disposable
Instance Method Details
#load(filename, cache_symbol) ⇒ self #load(bmp) ⇒ self Also known as: set_bitmap
Set the texture show on the screen surface
61 62 63 64 65 66 67 68 69 |
# File 'scripts/00000 Dependencies/00001 LiteRGSS2/00003 Drawable.rb', line 61 def load(texture, cache = nil, auto_rect = false) if cache && texture.is_a?(String) self.bitmap = RPG::Cache.send(cache, texture) set_rect_div(0, 0, 4, 4) if auto_rect && cache == :character else self.bitmap = texture end return self end |
#mouse_in?(mouse_x = Mouse.x, mouse_y = Mouse.y) ⇒ Boolean
Detect if the mouse is in the sprite (without rotation)
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'scripts/00700 Ajout_PSDK/01800 XXX_simple_mouse_in_.rb', line 26 def 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 - ox * (zx = zoom_x) by = y - oy * (zy = zoom_y) return false if mouse_x < bx || mouse_y < by bx += src_rect.width * zx by += src_rect.height * zy return false if mouse_x >= bx || mouse_y >= by true end |
#set_origin_div(ox, oy) ⇒ self
define the pixel of the bitmap that is shown at the coordinate of the sprite. The width and the height is divided by ox and oy to determine the pixel
23 24 25 26 27 |
# File 'scripts/00000 Dependencies/00001 LiteRGSS2/00003 Drawable.rb', line 23 def set_origin_div(ox, oy) self.ox = bitmap.width / ox self.oy = bitmap.height / oy return self end |
#set_rect(x, y, width, height) ⇒ self
Define the surface of the bitmap that is shown on the screen surface
35 36 37 38 |
# File 'scripts/00000 Dependencies/00001 LiteRGSS2/00003 Drawable.rb', line 35 def set_rect(x, y, width, height) src_rect.set(x, y, width, height) return self end |
#set_rect_div(x, y, width, height) ⇒ self
Define the surface of the bitmap that is shown with division of it
46 47 48 49 50 51 |
# File 'scripts/00000 Dependencies/00001 LiteRGSS2/00003 Drawable.rb', line 46 def set_rect_div(x, y, width, height) width = bitmap.width / width height = bitmap.height / height src_rect.set(x * width, y * height, width, height) return self end |
#set_z(z) ⇒ self
define the superiority of the sprite
13 14 15 16 |
# File 'scripts/00000 Dependencies/00001 LiteRGSS2/00003 Drawable.rb', line 13 def set_z(z) self.z = z return self end |
#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)
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'scripts/00700 Ajout_PSDK/01800 XXX_simple_mouse_in_.rb', line 7 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 += src_rect.width by += src_rect.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
45 46 47 48 49 50 51 52 53 |
# File 'scripts/00700 Ajout_PSDK/01800 XXX_simple_mouse_in_.rb', line 45 def translate_mouse_coords(mouse_x = Mouse.x, mouse_y = Mouse.y) mouse_x, mouse_y = .translate_mouse_coords(mouse_x, mouse_y) if mouse_x -= x mouse_y -= y rect = src_rect mouse_x += rect.x mouse_y += rect.y return mouse_x, mouse_y end |
#update
RGSS Compatibility “update” the sprite
6 7 8 |
# File 'scripts/00000 Dependencies/00001 LiteRGSS2/00003 Drawable.rb', line 6 def update return nil end |