Class: BattleUI::TrainerSprite

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

Overview

Sprite of a Trainer in the battle

Constant Summary collapse

FADE_AWAY_PIXEL_COUNT =

Number of pixels the sprite has to move in other to fade away from the scene

160
BACK_FRAME_COUNT =

Define the number of frames inside a back trainer

2

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, #set_origin, #set_position

Methods inherited from LiteRGSS::Disposable

#dispose, #disposed?

Constructor Details

#initialize(viewport, scene, battler, bank, position, battle_info) ⇒ TrainerSprite

Create a new TrainerSprite

Parameters:



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

def initialize(viewport, scene, battler, bank, position, battle_info)
  super(viewport)
  @animation_handler = Yuki::Animation::Handler.new
  @scene = scene
  @bank = bank
  @position = position
  @battle_info = battle_info
  set_bitmap(battler, :battler)
  src_rect.height = bitmap.height / BACK_FRAME_COUNT if @bank == 0
  reset_position
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})


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

def animation_handler
  @animation_handler
end

#bankInteger (readonly)

Get the bank of the pokemon shown by the sprite

Returns:



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

def bank
  @bank
end

#positionInteger (readonly)

Get the position of the pokemon shown by the sprite

Returns:



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

def position
  @position
end

#sceneBattle::Scene (readonly)

Get the scene linked to this object

Returns:



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

def scene
  @scene
end

Instance Method Details

#done?Boolean

Tell if the sprite animations are done

Returns:

  • (Boolean)


49
50
51
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00103 TrainerSprite.rb', line 49

def done?
  return @animation_handler.done?
end

#show_next_frame

Note:

Frames are ordered on the vertical axis

Set the battler on its next frame



55
56
57
58
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00103 TrainerSprite.rb', line 55

def show_next_frame
  new_y = src_rect.y + src_rect.height
  src_rect.y = new_y if new_y < bitmap.height
end

#show_previous_frame

Note:

Frames are ordered on the vertical axis

Set the battler on its previous frame



62
63
64
65
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00103 TrainerSprite.rb', line 62

def show_previous_frame
  new_y = src_rect.y - src_rect.height
  src_rect.y = new_y if new_y >= 0
end

#update

Update the sprite



43
44
45
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00103 TrainerSprite.rb', line 43

def update
  @animation_handler.update
end