Class: UI::Casino::NumberDisplay
- Inherits:
-
SpriteStack
- Object
- SpriteStack
- UI::Casino::NumberDisplay
- Defined in:
- scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00001 NumberDisplay.rb
Overview
Object showing images of credit / payout element in casino UI
Constant Summary collapse
- FILES =
List of files that shows the number
%w[casino/n0 casino/n1 casino/n2 casino/n3 casino/n4 casino/n5 casino/n6 casino/n7 casino/n8 casino/n9]
- DELTA =
Delta of number between each frame
3
Constants inherited from SpriteStack
Instance Attribute Summary collapse
-
#number ⇒ Integer
Number that is currently displayed.
-
#target ⇒ Integer
Target that the UI element should animatedly aim.
Attributes inherited from SpriteStack
#animated, #data, #moving, #stack, #viewport, #x, #y
Instance Method Summary collapse
-
#done? ⇒ Boolean
Tell if the animation is done.
-
#initialize(viewport, x, y, max_numbers) ⇒ NumberDisplay
constructor
Create a new NumberDipslay.
-
#update
Update the animation.
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, x, y, max_numbers) ⇒ NumberDisplay
Create a new NumberDipslay
23 24 25 26 27 28 29 30 31 |
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00001 NumberDisplay.rb', line 23 def initialize(, x, y, max_numbers) super(, x, y) width = number_width max_numbers.times do |i| add_sprite((max_numbers - i - 1) * width, 0, NO_INITIAL_IMAGE) end @number = 0 @target = 0 end |
Instance Attribute Details
#number ⇒ Integer
Number that is currently displayed
13 14 15 |
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00001 NumberDisplay.rb', line 13 def number @number end |
#target ⇒ Integer
Target that the UI element should animatedly aim
16 17 18 |
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00001 NumberDisplay.rb', line 16 def target @target end |
Instance Method Details
#done? ⇒ Boolean
Tell if the animation is done
54 55 56 |
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00001 NumberDisplay.rb', line 54 def done? @number == @target end |
#update
Update the animation
42 43 44 45 46 47 48 49 50 |
# File 'scripts/01450 Systems/09000 Games/00001 Slot Machines/00002 UI/00001 NumberDisplay.rb', line 42 def update return if done? if @target > @number @number = (@number + DELTA).clamp(@number, @target) else @number = (@number - DELTA).clamp(@target, @number) end update_numbers end |