Class: UI::DexButton

Inherits:
SpriteStack show all
Defined in:
scripts/01450 Systems/00101 Dex/00002 UI/01400 Dex UIs.rb

Overview

Dex sprite that show the Pokemon infos

Constant Summary

Constants inherited from SpriteStack

SpriteStack::NO_INITIAL_IMAGE

Instance Attribute Summary

Attributes inherited from SpriteStack

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

Instance Method Summary collapse

Methods inherited from 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) ⇒ DexButton

Create a new dex button

Parameters:

  • viewport (Viewport)
  • index (Integer)

    index of the sprite in the viewport



116
117
118
119
120
121
122
# File 'scripts/01450 Systems/00101 Dex/00002 UI/01400 Dex UIs.rb', line 116

def initialize(viewport, index)
  # Create the sprite stack at coordinate 147, 62 using the RPG::Cache.pokedex as image source
  super(viewport, 147, 62, default_cache: :pokedex)

  create_sprites
  fix_position(index)
end

Instance Method Details

#data=(pokemon)

Change the data

Parameters:

  • pokemon (PFM::Pokemon)

    the Pokemon shown by the button



126
127
128
129
# File 'scripts/01450 Systems/00101 Dex/00002 UI/01400 Dex UIs.rb', line 126

def data=(pokemon)
  super(pokemon)
  update_catch_icon_visibility
end

#selected=(value)

Tell the button if it's selected or not : change the obfuscator visibility & x position

Parameters:

  • value (Boolean)

    the selected state



133
134
135
136
# File 'scripts/01450 Systems/00101 Dex/00002 UI/01400 Dex UIs.rb', line 133

def selected=(value)
  @obfuscator.visible = !value
  set_position(value ? 147 : 163, y)
end