Class: UI::TextScroller
- Inherits:
-
SpriteStack
- Object
- SpriteStack
- UI::TextScroller
- Defined in:
- scripts/01450 Systems/00000 General/00100 UI Generics/00710 TextScroller.rb
Constant Summary collapse
- DOUBLE_COLUMN_SEP =
Separator for double column
' || '
Constants inherited from SpriteStack
Instance Attribute Summary
Attributes inherited from SpriteStack
#animated, #data, #moving, #stack, #viewport, #x, #y
Instance Method Summary collapse
-
#done? ⇒ Boolean
Tell if the scrolling is done.
-
#initialize(viewport, texts, line_height, speed) ⇒ TextScroller
constructor
Create a new text scroller.
-
#start(until_all_text_hidden: true)
Start the text scroll.
-
#update
Update the scrolling.
Methods inherited from SpriteStack
#[], #add_background, #add_line, #add_text, #anime, #anime_delta_set, #dispose, #each, #execute_anime, #move, #move_to, #opacity, #opacity=, #push, #push_sprite, #set_origin, #set_position, #simple_mouse_in?, #size, #stop_animation, #translate_mouse_coords, #update_animation, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=
Constructor Details
#initialize(viewport, texts, line_height, speed) ⇒ TextScroller
Create a new text scroller
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00710 TextScroller.rb', line 10 def initialize(, texts, line_height, speed) super(, 0, 0) @texts = texts @line_height = line_height @speed = speed @next_check = 0 @index = 0 @h1_pool = [] @h2_pool = [] @h3_pool = [] @p_pool = [] end |
Instance Method Details
#done? ⇒ Boolean
Tell if the scrolling is done
41 42 43 44 45 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00710 TextScroller.rb', line 41 def done? return true unless @animation return @animation.done? end |
#start(until_all_text_hidden: true)
Start the text scroll
25 26 27 28 29 30 31 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00710 TextScroller.rb', line 25 def start(until_all_text_hidden: true) size = @texts.size * @line_height size += @viewport.rect.height if until_all_text_hidden preload_texts @animation = Yuki::Animation.move_discreet(size / @speed, self, 0, 0, 0, -size) @animation.start end |
#update
Update the scrolling
34 35 36 37 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00710 TextScroller.rb', line 34 def update spawn_next_text if y <= @next_check @animation.update end |