Class: UI::SpriteStack

Inherits:
Object show all
Defined in:
docs/01450_Systems_00000_General_00100_UI_Generics.rb

Overview

Class that helps to define a single object constitued of various sprites. With this class you can move the sprites as a single sprite, change the data that generate the sprites and some other cool stuff

Direct Known Subclasses

BattleUI::AbilityBar, BattleUI::ExpDistribution, BattleUI::ExpDistribution::PokemonInfo, BattleUI::ExpDistribution::Statistics, BattleUI::GenericChoice, BattleUI::InfoBar, BattleUI::PlayerChoice::ItemInfo, BattleUI::PlayerChoice::SpecialButton, BattleUI::PlayerChoice::SubChoice, BattleUI::SkillChoice::MoveButton, BattleUI::SkillChoice::MoveDescription, BattleUI::SkillChoice::MoveInfo, BattleUI::SkillChoice::SpecialButton, BattleUI::SkillChoice::SubChoice, BattleUI::TargetSelection, BattleUI::TargetSelection::Button, BattleUI::TrainerPartyBalls, GTS::Button, GTS::LoadingScreen, Bag::ButtonList::ItemButton, Bag::InfoCompact, Bag::InfoWide, Bag::PocketList, Bag::ScrollBar, Bag::SearchBar, Bag::WinPocket, Casino::NumberDisplay, DexButton, DexSeenGot, DexWinInfo, DexWinMap, DexWinSprite, GenericBase, GenericBase::ControlButton, Hall_of_Fame::Congratulation_Text_Box, Hall_of_Fame::Dead_Pokemon_Text, Hall_of_Fame::End_Stars_Animation, Hall_of_Fame::Graveyard_Animation_Stack, Hall_of_Fame::League_Champion_Text_Box, Hall_of_Fame::Party_Battler_Stack, Hall_of_Fame::Pokemon_Battler_Stack, Hall_of_Fame::Pokemon_Stars_Animation, Hall_of_Fame::Pokemon_Text_Box, Hall_of_Fame::Trainer_Infos_Text_Box, Hall_of_Fame::Type_Background, InputNumber, KeyBindingViewer, MapPanel, MiningGame::Diggable_Stack, MiningGame::Hit_Counter_Stack, MiningGame::Tiles_Stack, MiningGame::Tool_Buttons, MoveTeaching::BaseBackground, MoveTeaching::NewSkill, MoveTeaching::PokemonInfos, MoveTeaching::Skill, MoveTeaching::SkillDescription, Options::Button, Options::Description, PSDKMenuButton, Quest::CategoryDisplay, Quest::Composition, Quest::ObjectiveList, Quest::QuestButton, Quest::QuestList, Quest::RewardButton, Quest::RewardScreen, Quest::ScrollBar, QuestInformer, SaveSign, UI::Shop::ItemDesc, UI::Shop::ItemList::ListButton, UI::Shop::MoneyWindow, UI::Shop::PkmDesc, UI::Shop::PkmList::ListButtonPkm, UI::Shop::PkmScrollBar, UI::Shop::ScrollBar, ShortcutElement, UI::Storage::BoxStack, UI::Storage::Composition, UI::Storage::DetailedSearch, UI::Storage::PartyStack, UI::Storage::RapidSearch, UI::Storage::Summary, Summary_Memo, Summary_Skill, Summary_Skills, Summary_Stat, Summary_Top, TeamButton, TextScroller, TitleControls, VoltorbFlip::Animation, VoltorbFlip::BoardCounter, VoltorbFlip::BoardTile, VoltorbFlip::Texts

Constant Summary collapse

NO_INITIAL_IMAGE =

Constant specifiying the sprite will have no image during initialization

nil

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(viewport, x = 0, y = 0, default_cache: :interface) ⇒ SpriteStack

Create a new Sprite stack

Parameters:

  • viewport (Viewport)

    the viewport where the sprites will be shown

  • x (Numeric) (defaults to: 0)

    the x position of the sprite stack

  • y (Numeric) (defaults to: 0)

    the y position of the sprite stack

  • default_cache (Symbol) (defaults to: :interface)

    the RPG::Cache function to call when setting the bitmap



26
27
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 26

def initialize(viewport, x = 0, y = 0, default_cache: :interface)
end

Instance Attribute Details

#animatedBoolean

>>> Section from Yuki::Sprite <<< If the sprite has a self animation

Returns:

  • (Boolean)


178
179
180
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 178

def animated
  @animated
end

#data

Data used by the sprites of the sprite stack to generate themself



15
16
17
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 15

def data
  @data
end

#movingBoolean

If the sprite is moving

Returns:

  • (Boolean)


181
182
183
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 181

def moving
  @moving
end

#stack (readonly)

Get the stack



17
18
19
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 17

def stack
  @stack
end

#viewportViewport (readonly)

Get the viewport

Returns:



20
21
22
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 20

def viewport
  @viewport
end

#xNumeric

X coordinate of the sprite stack

Returns:

  • (Numeric)


10
11
12
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 10

def x
  @x
end

#yNumeric

Y coordinate of the sprite stack

Returns:

  • (Numeric)


13
14
15
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 13

def y
  @y
end

Instance Method Details

#[](index) ⇒ Sprite, Text

Return an element of the stack

Parameters:

  • index (Integer)

    index of the element in the stack

Returns:



110
111
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 110

def [](index)
end

#add_background(filename, type: Sprite, rect: nil) ⇒ Sprite Also known as: add_foreground

Push a background image

Parameters:

  • filename (String)

    name of the image in the cache

  • rect (Array, nil) (defaults to: nil)

    the src_rect.set arguments if required

  • type (Class) (defaults to: Sprite)

    the class to use to generate the sprite

Returns:



58
59
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 58

def add_background(filename, type: Sprite, rect: nil)
end

#add_line(line_index, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: nil, dx: 0) ⇒ Text

Add a text inside the stack using metrics given by with_surface

Parameters:

  • line_index (Integer)

    index of the line in the surface

  • str (String)

    the text shown by this object

  • align (0, 1, 2) (defaults to: 0)

    the align of the text in its surface (best effort => no resize), 0 = left, 1 = center, 2 = right

  • outlinesize (Integer, nil) (defaults to: Text::Util::DEFAULT_OUTLINE_SIZE)

    the size of the text outline

  • type (Class) (defaults to: Text)

    the type of text

  • color (Integer) (defaults to: nil)

    the id of the color

  • dx (Integer) (defaults to: 0)

    offset x to use “table like” display (this value is multiplied by width)

Returns:

  • (Text)

    the text object



105
106
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 105

def add_line(line_index, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: nil, dx: 0)
end

#add_text(x, y, width, height, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: nil, sizeid: nil) ⇒ Text

Add a text inside the stack, the offset x/y will be adjusted

Parameters:

  • x (Integer)

    the x coordinate of the text surface

  • y (Integer)

    the y coordinate of the text surface

  • width (Integer)

    the width of the text surface

  • height (Integer, nil)

    the height of the text surface (if nil, uses the line_height from sizeid)

  • str (String)

    the text shown by this object

  • align (0, 1, 2) (defaults to: 0)

    the align of the text in its surface (best effort => no resize), 0 = left, 1 = center, 2 = right

  • outlinesize (Integer, nil) (defaults to: Text::Util::DEFAULT_OUTLINE_SIZE)

    the size of the text outline

  • type (Class) (defaults to: Text)

    the type of text

  • color (Integer) (defaults to: nil)

    the id of the color

Returns:

  • (Text)

    the text object



51
52
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 51

def add_text(x, y, width, height, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: nil, sizeid: nil)
end

#anime(arr, delta = 1)

Start an animation

Parameters:

  • arr (Array<Array(Symbol, *args)>)

    Array of message

  • delta (Integer) (defaults to: 1)

    Number of frame to wait between each animation message



197
198
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 197

def anime(arr, delta = 1)
end

#anime_delta_set(v)

Change the time to wait between each animation message

Parameters:

  • v (Integer)


214
215
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 214

def anime_delta_set(v)
end

#dispose

Dispose each sprite of the sprite stack and clear the stack



173
174
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 173

def dispose
end

#each(&block)

yield a block on each sprite

Parameters:

  • block (Proc)


170
171
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 170

def each(&block)
end

#execute_anime(n)

Note:

this method is used in animation message Array

Force the execution of the n next animation message

Parameters:

  • n (Integer)

    Number of animation message to execute



206
207
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 206

def execute_anime(n)
end

#move(delta_x, delta_y) ⇒ self

Move the sprite stack

Parameters:

  • delta_x (Numeric)

    number of pixel the sprite stack should be moved in x

  • delta_y (Numeric)

    number of pixel the sprite stack should be moved in y

Returns:

  • (self)


135
136
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 135

def move(delta_x, delta_y)
end

#move_to(x, y, nb_frame)

Move the sprite to a specific coordinate in a certain amount of frame

Parameters:

  • x (Integer)

    new x Coordinate

  • y (Integer)

    new y Coordinate

  • nb_frame (Integer)

    number of frame to go to the new coordinate



189
190
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 189

def move_to(x, y, nb_frame)
end

#opacityInteger

Gets the opacity of the SpriteStack

Returns:

  • (Integer)


218
219
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 218

def opacity
end

#opacity=(value)

Sets the opacity of the SpriteStack

Parameters:

  • value (Integer)

    the new opacity value



222
223
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 222

def opacity=(value)
end

#push(x, y, bmp, *args, rect: nil, type: Sprite, ox: 0, oy: 0) ⇒ Sprite Also known as: add_sprite

Push a sprite to the stack

Parameters:

  • x (Numeric)

    the relative x position of the sprite in the stack (sprite.x = stack.x + x)

  • y (Numeric)

    the relative y position of the sprite in the stack (sprite.y = stack.y + y)

  • args (Array)

    the arguments after the viewport argument of the sprite to create the sprite

  • rect (Array, nil) (defaults to: nil)

    the src_rect.set arguments if required

  • type (Class) (defaults to: Sprite)

    the class to use to generate the sprite

  • ox (Numeric) (defaults to: 0)

    the ox of the sprite

  • oy (Numeric) (defaults to: 0)

    the oy of the sprite

Returns:

  • (Sprite)

    the pushed sprite



37
38
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 37

def push(x, y, bmp, *args, rect: nil, type: Sprite, ox: 0, oy: 0)
end

#push_sprite(sprite) ⇒ sprite Also known as: add_custom_sprite

Push a sprite object to the stack

Parameters:

Returns:

  • (sprite)


64
65
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 64

def push_sprite(sprite)
end

#set_origin(_ox, _oy)

Note:

this function is only for compatibility, it does nothing

Set the origin (does nothing)

Parameters:

  • _ox (Integer)

    new origin x

  • _oy (Integer)

    new origin y



141
142
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 141

def set_origin(_ox, _oy)
end

#set_position(x, y) ⇒ self

Change the x and y coordinate of the sprite stack

Parameters:

  • x (Numeric)

    the new x value

  • y (Numeric)

    the new y value

Returns:

  • (self)


129
130
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 129

def set_position(x, y)
end

#simple_mouse_in?(mx = Mouse.x, my = Mouse.y) ⇒ Boolean

Detect if the mouse is in the first sprite of the stack

Parameters:

  • mx (Numeric) (defaults to: Mouse.x)

    mouse x coordinate

  • my (Numeric) (defaults to: Mouse.y)

    mouse y coordinate

Returns:

  • (Boolean)


156
157
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 156

def simple_mouse_in?(mx = Mouse.x, my = Mouse.y)
end

#sizeInteger Also known as: length

Return the size of the stack

Returns:

  • (Integer)


114
115
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 114

def size
end

#stop_animation

Note:

this method is used in the animation message Array (because animation loops)

Stop the animation



210
211
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 210

def stop_animation
end

#translate_mouse_coords(mx = Mouse.x, my = Mouse.y) ⇒ Array(Numeric, Numeric)

Translate the mouse coordinate to mouse position inside the first sprite of the stack

Parameters:

  • mx (Numeric) (defaults to: Mouse.x)

    mouse x coordinate

  • my (Numeric) (defaults to: Mouse.y)

    mouse y coordinate

Returns:

  • (Array(Numeric, Numeric))


162
163
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 162

def translate_mouse_coords(mx = Mouse.x, my = Mouse.y)
end

#update

Update sprite (+move & animation)



183
184
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 183

def update
end

#update_animation(no_delta)

Update the animation

Parameters:

  • no_delta (Boolean)

    if the number of frame to wait between each animation message is skiped



201
202
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 201

def update_animation(no_delta)
end

#update_position

Update the movement



192
193
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 192

def update_position
end

#visibleBoolean

Note:

Return the visible property of the first sprite

If the sprite stack is visible

Returns:

  • (Boolean)


146
147
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 146

def visible
end

#visible=(value)

Change the visible property of each sprites

Parameters:

  • value (Boolean)


150
151
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 150

def visible=(value)
end

#with_cache(cache)

Execute push operations with an alternative cache

Examples:

with_cache(:pokedex) { add_background('win_sprite') }

Parameters:

  • cache (Symbol)

    function of RPG::Cache used to load images



72
73
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 72

def with_cache(cache)
end

#with_font(font_id)

Execute add_text operation with an alternative font

Examples:

with_font(2) { add_text(0, 0, 320, 32, 'Big Text', 1) }

Parameters:

  • font_id (Integer)

    id of the font



79
80
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 79

def with_font(font_id)
end

#with_surface(x, y, unit_width, size_id = 0, offset_width = 2)

Execute add_line with specific metrics info

Examples:

with_surface(x, y, unit_width, size_id) do
  add_line(0, "Centered", 1)
  add_line(1, "Left Red", color: 2)
  add_line(2, "Right Blue", 2, color: 1)
  add_line(0, "Centered on next surface", 1, dx: 1)
end

Parameters:

  • x (Integer)

    X position of the surface

  • y (Integer)

    Y position of the surface

  • unit_width (Integer)

    Width of the line (for alignment and offset x)

  • size_id (Integer) (defaults to: 0)

    Size to use to get the right metrics

  • offset_width (Integer) (defaults to: 2)

    offset between each columns when dx: is used



94
95
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 94

def with_surface(x, y, unit_width, size_id = 0, offset_width = 2)
end

#zNumeric

Gets the z of the SpriteStack

Returns:

  • (Numeric)


226
227
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 226

def z
end

#z=(value)

Sets the z of the SpriteStack



229
230
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 229

def z=(value)
end