Class: UI::ThrowingBallSprite

Inherits:
SpriteSheet show all
Defined in:
scripts/01450 Systems/00000 General/00100 UI Generics/00700 ThrowingBallSprite.rb

Overview

Sprite responsive of showing the sprite of the Ball we throw to Pokemon or to release Pokemon

Constant Summary collapse

MOVE_PROGRESSION_CELL =

Array mapping the move progression to the right cell

[17, 16, 15, 16, 17, 18, 19, 18, 17]

Instance Attribute Summary

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, #update

Methods inherited from LiteRGSS::Sprite

new, #set_origin, #set_position

Methods inherited from LiteRGSS::Disposable

#dispose, #disposed?

Constructor Details

#initialize(viewport, pokemon_or_item) ⇒ ThrowingBallSprite

Create a new ThrowingBallSprite

Parameters:



9
10
11
12
13
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00700 ThrowingBallSprite.rb', line 9

def initialize(viewport, pokemon_or_item)
  super(viewport, 1, 32)
  resolve_image(pokemon_or_item)
  self.sy = 3
end

Instance Method Details

#ball_offset_yInteger

Get the ball offset y in order to make it the same position as the Pokemon sprite

Returns:



63
64
65
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00700 ThrowingBallSprite.rb', line 63

def ball_offset_y
  return 8
end

#break_progression=(progression)

Function that adjust the sy depending on the progression of the “break” animation

Parameters:

  • progression (Float)


46
47
48
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00700 ThrowingBallSprite.rb', line 46

def break_progression=(progression)
  self.sy = (progression * 7).floor.clamp(0, 6) + 20
end

#caught_progression=(progression)

Function that adjust the sy depending on the progression of the “caught” animation

Parameters:

  • progression (Float)


52
53
54
55
56
57
58
59
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00700 ThrowingBallSprite.rb', line 52

def caught_progression=(progression)
  target = (progression * 5).floor
  if target == 5
    self.sy = 17
  else
    self.sy = 27 + target
  end
end

#close_progression=(progression)

Function that adjust the sy depending on the progression of the “close” animation

Parameters:

  • progression (Float)


29
30
31
32
33
34
35
36
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00700 ThrowingBallSprite.rb', line 29

def close_progression=(progression)
  target = (progression * 9).floor
  if target == 9
    self.sy = 3
  else
    self.sy = target + 6
  end
end

#move_progression=(progression)

Function that adjust the sy depending on the progression of the “move” animation

Parameters:

  • progression (Float)


40
41
42
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00700 ThrowingBallSprite.rb', line 40

def move_progression=(progression)
  self.sy = MOVE_PROGRESSION_CELL[(progression * 8).floor]
end

#open_progression=(progression)

Function that adjust the sy depending on the progression of the “open” animation

Parameters:

  • progression (Float)


23
24
25
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00700 ThrowingBallSprite.rb', line 23

def open_progression=(progression)
  self.sy = (progression * 2).floor.clamp(0, 1) + 4
end

#throw_progression=(progression)

Function that adjust the sy depending on the progression of the “throw” animation

Parameters:

  • progression (Float)


17
18
19
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00700 ThrowingBallSprite.rb', line 17

def throw_progression=(progression)
  self.sy = (progression * 4).floor.clamp(0, 3)
end

#trainer_offset_yInteger

Get the ball offset y in order to make it look like being in trainer's hand

Returns:



69
70
71
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00700 ThrowingBallSprite.rb', line 69

def trainer_offset_y
  return 40
end