Class: BattleUI::TargetSelection::Button

Inherits:
UI::SpriteStack show all
Defined in:
scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00400 TargetSelection.rb

Overview

Button shown by the UI to get what's selected

Defined Under Namespace

Classes: Background

Constant Summary

Constants inherited from UI::SpriteStack

UI::SpriteStack::NO_INITIAL_IMAGE

Instance Attribute Summary collapse

Attributes inherited from UI::SpriteStack

#animated, #data, #moving, #stack, #viewport, #x, #y

Instance Method Summary collapse

Methods inherited from UI::SpriteStack

#[], #add_background, #add_line, #add_text, #anime, #anime_delta_set, #dispose, #each, #execute_anime, #move, #move_to, #opacity, #opacity=, #push, #push_sprite, #set_origin, #set_position, #simple_mouse_in?, #size, #stop_animation, #translate_mouse_coords, #update, #update_animation, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=

Constructor Details

#initialize(viewport, index, row_size, pokemon, launcher, move, is_target) ⇒ Button

Create a new button

Parameters:



130
131
132
133
134
135
136
137
138
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00400 TargetSelection.rb', line 130

def initialize(viewport, index, row_size, pokemon, launcher, move, is_target)
  super(viewport, *process_coordinates(index, row_size))
  create_sprites
  @move = move
  @selected = is_target
  @is_target = is_target
  @launcher = launcher
  self.data = pokemon
end

Instance Attribute Details

#cursorCursor (readonly)

Get the cursor

Returns:



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

def cursor
  @cursor
end

#selectedBoolean

Get the selected state of the button

Returns:

  • (Boolean)


117
118
119
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00400 TargetSelection.rb', line 117

def selected
  @selected
end

Instance Method Details

#data=(pokemon)

Set the Pokemon shown

Parameters:



151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00400 TargetSelection.rb', line 151

def data=(pokemon)
  super(pokemon)
  self.visible = pokemon&.alive?
  unless visible
    @background.visible = true
    return
  end

  @gender.x = @name.x + @name.real_width + 5
  @icon.opacity = @is_target ? 255 : 128
  @efficiency_text.text = load_efficiency_text(pokemon)
  @efficiency_text.visible = @is_target
  self.selected = @selected
end