Class: UI::JKeyBinding
- Inherits:
-
Sprite
- Object
- LiteRGSS::Disposable
- LiteRGSS::Drawable
- LiteRGSS::Sprite
- LiteRGSS::ShaderedSprite
- Sprite
- UI::JKeyBinding
- Defined in:
- scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb
Overview
Class that allow to show a binding of a specific key on the Joypad
Constant Summary collapse
- KeyIndex =
KeyIndex that holds the value of the key value in the order of the texture
[ 0, 1, 2, 3, 13, 15, 12, 14, 8, 9, 4, 5, 6, 7, 10, 11 ]
Instance Attribute Summary collapse
-
#key ⇒ Symbol
readonly
The key the button describe.
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
-
#find_key(key)
Find the key rect in the Sprite according to the input key requested.
-
#index ⇒ Integer
Return the index of the key in the Keys array.
-
#initialize(viewport, key) ⇒ JKeyBinding
constructor
Create a new KeyBinding sprite.
-
#update
Update the key.
Methods inherited from Sprite
#load, #mouse_in?, #set_origin_div, #set_rect, #set_rect_div, #set_z, #simple_mouse_in?, #translate_mouse_coords
Methods inherited from LiteRGSS::Sprite
new, #set_origin, #set_position
Methods inherited from LiteRGSS::Disposable
Constructor Details
#initialize(viewport, key) ⇒ JKeyBinding
Create a new KeyBinding sprite
86 87 88 89 90 91 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb', line 86 def initialize(, key) super() @key = key set_bitmap('key_short_xbox', :pokedex) find_key(key) end |
Instance Attribute Details
#key ⇒ Symbol (readonly)
Returns the key the button describe.
82 83 84 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb', line 82 def key @key end |
Instance Method Details
#find_key(key)
Find the key rect in the Sprite according to the input key requested
99 100 101 102 103 104 105 106 107 108 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb', line 99 def find_key(key) key_val = Input::Keys[key].last if key_val && key_val < 0 key_val = (key_val.abs - 1) % 32 if (id = KeyIndex.index(key_val)) return set_rect_div(id % 8, id / 8, 8, 5) end end set_rect_div(0, 4, 8, 5) # A blank key end |
#index ⇒ Integer
Return the index of the key in the Keys array
117 118 119 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb', line 117 def index return Input::Keys[key].size - 1 end |
#update
Update the key
111 112 113 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb', line 111 def update find_key(@key) end |