Class: BattleUI::PokemonSprite
- Inherits:
-
ShaderedSprite
- Object
- LiteRGSS::Disposable
- LiteRGSS::Drawable
- LiteRGSS::Sprite
- LiteRGSS::ShaderedSprite
- Sprite
- ShaderedSprite
- BattleUI::PokemonSprite
- 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
-
#animation_handler ⇒ Yuki::Animation::Handler{ Symbol => Yuki::Animation::TimedAnimation}
readonly
Get the animation handler.
-
#bank ⇒ Integer
readonly
Get the bank of the pokemon shown by the sprite.
-
#pokemon ⇒ PFM::PokemonBattler
Get the Pokemon shown by the sprite.
-
#position ⇒ Integer
readonly
Get the position of the pokemon shown by the sprite.
-
#scene ⇒ Battle::Scene
readonly
Get the scene linked to this object.
-
#selected ⇒ Boolean
Tell if the sprite is currently selected.
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
-
#bitmap=(bitmap)
Set the bitmap of the sprite.
-
#cry(dying = false)
Play the cry of the Pokemon.
-
#done? ⇒ Boolean
Tell if the sprite animations are done.
-
#flee_animation ⇒ Yuki::Animation::TimedAnimation
Creates the flee animation.
-
#initialize(viewport, scene) ⇒ PokemonSprite
constructor
Create a new PokemonSprite.
-
#opacity=(opacity)
Set the opacity of the sprite.
-
#set_origin(ox, oy) ⇒ self
Set the origin of the sprite & the shadow.
-
#set_position(x, y) ⇒ self
Set the position of the sprite.
-
#update
Update the sprite.
-
#visible=(visible)
Set the visibility of the sprite.
-
#x=(x)
Set the x position of the sprite.
-
#y=(y)
Set the y position of the sprite.
-
#zoom=(zoom)
Set the zoom of the sprite.
Methods included from MultiplePosition
Methods included from GoingInOut
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
Methods inherited from LiteRGSS::Disposable
Constructor Details
#initialize(viewport, scene) ⇒ PokemonSprite
Create a new PokemonSprite
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(, scene) super() @shadow = ShaderedSprite.new() @shadow.shader = Shader.create(:battle_shadow) @animation_handler = Yuki::Animation::Handler.new @bank = 0 @position = 0 @scene = scene end |
Instance Attribute Details
#animation_handler ⇒ Yuki::Animation::Handler{ Symbol => Yuki::Animation::TimedAnimation} (readonly)
Get the animation handler
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 |
#bank ⇒ Integer (readonly)
Get the bank of the pokemon shown by the sprite
22 23 24 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 22 def bank @bank end |
#pokemon ⇒ PFM::PokemonBattler
Get the Pokemon shown by the sprite
13 14 15 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 13 def pokemon @pokemon end |
#position ⇒ Integer (readonly)
Get the position of the pokemon shown by the sprite
19 20 21 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 19 def position @position end |
#scene ⇒ Battle::Scene (readonly)
Get the scene linked to this object
25 26 27 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 25 def scene @scene end |
#selected ⇒ Boolean
Tell if the sprite is currently selected
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
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
66 67 68 69 70 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00100 PokemonSprite.rb', line 66 def cry( = false) return unless pokemon Audio.se_play(pokemon.cry, 100, ? 80 : 100) end |
#done? ⇒ Boolean
Tell if the sprite animations are done
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_animation ⇒ Yuki::Animation::TimedAnimation
Creates the flee animation
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? ? .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
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
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
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
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
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
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
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 |