Class: BattleUI::PokemonSprite

Inherits:
ShaderedSprite show all
Includes:
GoingInOut, MultiplePosition
Defined in:
scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb

Overview

Sprite of a Pokemon in the battle

Constant Summary collapse

DELTA_DEATH_Y =

Constant giving the deat Delta Y (you need to adjust that so your screen animation are OK when Pokemon are KO)

32

Instance Attribute Summary collapse

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 included from MultiplePosition

#enemy?

Methods included from GoingInOut

#go_in, #go_out, #in?, #out?

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

Methods inherited from LiteRGSS::Disposable

#dispose, #disposed?

Constructor Details

#initialize(viewport, scene) ⇒ PokemonSprite

Create a new PokemonSprite

Parameters:



30
31
32
33
34
35
36
37
38
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 30

def initialize(viewport, scene)
  super(viewport)
  @shadow = ShaderedSprite.new(viewport)
  @shadow.shader = Shader.create(:battle_shadow)
  @animation_handler = Yuki::Animation::Handler.new
  @bank = 0
  @position = 0
  @scene = scene
end

Instance Attribute Details

#animation_handlerYuki::Animation::Handler{ Symbol => Yuki::Animation::TimedAnimation} (readonly)

Get the animation handler

Returns:

  • (Yuki::Animation::Handler{ Symbol => Yuki::Animation::TimedAnimation})


16
17
18
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 16

def animation_handler
  @animation_handler
end

#bankInteger (readonly)

Get the bank of the pokemon shown by the sprite

Returns:



22
23
24
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 22

def bank
  @bank
end

#pokemonPFM::PokemonBattler

Get the Pokemon shown by the sprite

Returns:



13
14
15
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 13

def pokemon
  @pokemon
end

#positionInteger (readonly)

Get the position of the pokemon shown by the sprite

Returns:



19
20
21
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 19

def position
  @position
end

#sceneBattle::Scene (readonly)

Get the scene linked to this object

Returns:



25
26
27
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 25

def scene
  @scene
end

#selectedBoolean

Tell if the sprite is currently selected

Returns:

  • (Boolean)


10
11
12
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 10

def selected
  @selected
end

Instance Method Details

#bitmap=(bitmap)

Set the bitmap of the sprite

Parameters:



120
121
122
123
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 120

def bitmap=(bitmap)
  @shadow.bitmap = bitmap
  super
end

#cry(dying = false)

Play the cry of the Pokemon

Parameters:

  • dying (Boolean) (defaults to: false)

    if the Pokemon is dying



66
67
68
69
70
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 66

def cry(dying = false)
  return unless pokemon

  Audio.se_play(pokemon.cry, 100, dying ? 80 : 100)
end

#done?Boolean

Tell if the sprite animations are done

Returns:

  • (Boolean)


48
49
50
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 48

def done?
  return @animation_handler.done?
end

#flee_animationYuki::Animation::TimedAnimation

Creates the flee animation

Returns:

  • (Yuki::Animation::TimedAnimation)


134
135
136
137
138
139
140
141
142
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 134

def flee_animation
  bx = enemy? ? viewport.rect.width + width : -width
  ya = Yuki::Animation
  animation = ya.move(0.5, self, x, y, bx, y)
  animation.parallel_add(ya::ScalarAnimation.new(0.5, self, :opacity=, 255, 0))
  animation.parallel_add(ya.se_play('fleee', 100, 60))
  animation.start
  animation_handler[:in_out] = animation
end

#opacity=(opacity)

Set the opacity of the sprite

Parameters:



113
114
115
116
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 113

def opacity=(opacity)
  @shadow.opacity = opacity
  super
end

#set_origin(ox, oy) ⇒ self

Set the origin of the sprite & the shadow

Parameters:

  • ox (Numeric)
  • oy (Numeric)

Returns:

  • (self)


76
77
78
79
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 76

def set_origin(ox, oy)
  @shadow.set_origin(ox, oy)
  super
end

#set_position(x, y) ⇒ self

Set the position of the sprite

Parameters:

  • x (Numeric)
  • y (Numeric)

Returns:

  • (self)


92
93
94
95
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 92

def set_position(x, y)
  @shadow.set_position(x, y)
  super
end

#update

Update the sprite



41
42
43
44
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 41

def update
  @animation_handler.update
  @gif&.update(bitmap) unless pokemon&.dead?
end

#visible=(visible)

Set the visibility of the sprite

Parameters:

  • visible (Boolean)


127
128
129
130
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 127

def visible=(visible)
  @shadow.visible = visible
  super
end

#x=(x)

Set the x position of the sprite

Parameters:

  • x (Numeric)


106
107
108
109
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 106

def x=(x)
  @shadow.x = x
  super
end

#y=(y)

Set the y position of the sprite

Parameters:

  • y (Numeric)


99
100
101
102
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 99

def y=(y)
  @shadow.y = y
  super
end

#zoom=(zoom)

Set the zoom of the sprite

Parameters:

  • zoom (Float)


83
84
85
86
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 83

def zoom=(zoom)
  @shadow.zoom = zoom
  super
end