Class: UI::Hall_of_Fame::Star_Animation

Inherits:
SpriteSheet show all
Defined in:
scripts/01450 Systems/00300 Hall of fame/00002 UI/00003 Stars_Animation.rb

Overview

Class that define the Star Animation

Instance Attribute Summary collapse

Attributes inherited from SpriteSheet

#nb_x, #nb_y, #sx, #sy

Attributes inherited from LiteRGSS::ShaderedSprite

#blendmode, #shader

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

Methods inherited from SpriteSheet

#bitmap=, #select

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

#dispose, #disposed?

Constructor Details

#initialize(viewport, frame_count = 2, repeat: false) ⇒ Star_Animation

Initialize the SpriteSheet

Parameters:

  • viewport (Viewport)
  • frame_count (Integer) (defaults to: 2)

    how many frames between each anim update

  • repeat (Boolean) (defaults to: false)

    if the animation has to repeat itself



15
16
17
18
19
20
21
22
23
24
25
# File 'scripts/01450 Systems/00300 Hall of fame/00002 UI/00003 Stars_Animation.rb', line 15

def initialize(viewport, frame_count = 2, repeat: false)
  super(viewport, 6, 1)
  set_bitmap('hall_of_fame/stars', :interface)
  set_position(x, y)
  self.opacity = 0
  @frame_count = frame_count
  @repeat = repeat
  @finished = false
  @counter = 0
  @reversing = false
end

Instance Attribute Details

#counterInteger

The counter for the animation

Returns:



7
8
9
# File 'scripts/01450 Systems/00300 Hall of fame/00002 UI/00003 Stars_Animation.rb', line 7

def counter
  @counter
end

#finishedBoolean

Tell if the animation is finished or not

Returns:

  • (Boolean)


10
11
12
# File 'scripts/01450 Systems/00300 Hall of fame/00002 UI/00003 Stars_Animation.rb', line 10

def finished
  @finished
end

Instance Method Details

#update

Update the animation depending on the @frame_count



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'scripts/01450 Systems/00300 Hall of fame/00002 UI/00003 Stars_Animation.rb', line 28

def update
  return if @finished

  if @counter == @frame_count
    @counter = 0
    if @reversing == true
      self.sx -= 1
      if self.sx == 0
        self.opacity = 0
        @reversing = false
        @finished = true if !@repeat
      end
    elsif @reversing == false
      self.opacity = 255 if self.sx == 0
      self.sx += 1
      @reversing = true if self.sx == 5
    end
  end
  @counter += 1
end