Class: UI::Bag::BagSprite
- Inherits:
-
SpriteSheet
- Object
- LiteRGSS::Disposable
- LiteRGSS::Drawable
- LiteRGSS::Sprite
- LiteRGSS::ShaderedSprite
- Sprite
- ShaderedSprite
- SpriteSheet
- UI::Bag::BagSprite
- Defined in:
- scripts/01450 Systems/00103 Bag/00002 UI/00040 BagSprite.rb
Overview
Class that show the bag sprite in the Bag UI
Constant Summary collapse
- POCKET_TRANSLATION =
Array translating real pocket id to sprite piece
[0, 0, 1, 3, 5, 4, 2, 6, 7]
- COORDINATES =
Coordinates of the bag
[71, 103]
Instance Attribute Summary collapse
-
#index ⇒ Integer
The current socket index.
Attributes inherited from SpriteSheet
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
-
#animate(target_index)
Start the animation between socket.
-
#done? ⇒ Boolean
Test if the animation is done.
-
#initialize(viewport, pocket_indexes) ⇒ BagSprite
constructor
Create a new Bah Sprite.
-
#mid? ⇒ Boolean
Test if the animation is at the middle of its progression.
-
#update
Update the animation.
Methods inherited from SpriteSheet
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, pocket_indexes) ⇒ BagSprite
Create a new Bah Sprite
14 15 16 17 18 19 |
# File 'scripts/01450 Systems/00103 Bag/00002 UI/00040 BagSprite.rb', line 14 def initialize(, pocket_indexes) super(, 1, 8) @index = 0 @pocket_indexes = pocket_indexes init_sprite end |
Instance Attribute Details
#index ⇒ Integer
Returns the current socket index.
6 7 8 |
# File 'scripts/01450 Systems/00103 Bag/00002 UI/00040 BagSprite.rb', line 6 def index @index end |
Instance Method Details
#animate(target_index)
Start the animation between socket
28 29 30 31 |
# File 'scripts/01450 Systems/00103 Bag/00002 UI/00040 BagSprite.rb', line 28 def animate(target_index) @target_index = target_index.clamp(0, 7) @counter = 0 end |
#done? ⇒ Boolean
Test if the animation is done
52 53 54 |
# File 'scripts/01450 Systems/00103 Bag/00002 UI/00040 BagSprite.rb', line 52 def done? @counter >= 8 end |
#mid? ⇒ Boolean
Test if the animation is at the middle of its progression
58 59 60 |
# File 'scripts/01450 Systems/00103 Bag/00002 UI/00040 BagSprite.rb', line 58 def mid? @counter == 4 end |
#update
Update the animation
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'scripts/01450 Systems/00103 Bag/00002 UI/00040 BagSprite.rb', line 34 def update return if done? if @counter < 2 self.x = COORDINATES.first - @counter elsif @counter < 4 self.x = COORDINATES.first - 4 + @counter elsif @counter == 4 self.index = @target_index elsif @counter < 6 self.x = COORDINATES.first + @counter - 4 else self.x = COORDINATES.first + 8 - @counter end @counter += 1 end |