Class: Sprite_Battler
- Inherits:
-
Sprite_Base
- Object
- Sprite
- Sprite_Base
- Sprite_Battler
- Defined in:
- lib/rgss3_default_scripts/Sprite_Battler.rb
Overview
** Sprite_Battler
This sprite is used to display battlers. It observes an instance of the
Game_Battler class and automatically changes sprite states.
Instance Attribute Summary collapse
-
#battler ⇒ Object
————————————————————————– * Public Instance Variables ————————————————————————–.
Instance Method Summary collapse
-
#dispose ⇒ Object
————————————————————————– * Free ————————————————————————–.
-
#effect? ⇒ Boolean
————————————————————————– * Determine if Effect Is Executing ————————————————————————–.
-
#init_visibility ⇒ Object
————————————————————————– * Initialize Visibility ————————————————————————–.
-
#initialize(viewport, battler = nil) ⇒ Sprite_Battler
constructor
————————————————————————– * Object Initialization ————————————————————————–.
-
#revert_to_normal ⇒ Object
————————————————————————– * Revert to Normal Settings ————————————————————————–.
-
#setup_new_animation ⇒ Object
————————————————————————– * Set New Animation ————————————————————————–.
-
#setup_new_effect ⇒ Object
————————————————————————– * Set New Effect ————————————————————————–.
-
#start_effect(effect_type) ⇒ Object
————————————————————————– * Start Effect ————————————————————————–.
-
#update ⇒ Object
————————————————————————– * Frame Update ————————————————————————–.
-
#update_appear ⇒ Object
————————————————————————– * Update Appearance Effect ————————————————————————–.
-
#update_bitmap ⇒ Object
————————————————————————– * Update Transfer Origin Bitmap ————————————————————————–.
-
#update_blink ⇒ Object
————————————————————————– * Update Blink Effect ————————————————————————–.
-
#update_boss_collapse ⇒ Object
————————————————————————– * Update Boss Collapse Effect ————————————————————————–.
-
#update_collapse ⇒ Object
————————————————————————– * Update Collapse Effect ————————————————————————–.
-
#update_disappear ⇒ Object
————————————————————————– * Updated Disappear Effect ————————————————————————–.
-
#update_effect ⇒ Object
————————————————————————– * Update Effect ————————————————————————–.
-
#update_instant_collapse ⇒ Object
————————————————————————– * Update Instant Collapse Effect ————————————————————————–.
-
#update_origin ⇒ Object
————————————————————————– * Update Origin ————————————————————————–.
-
#update_position ⇒ Object
————————————————————————– * Update Position ————————————————————————–.
-
#update_whiten ⇒ Object
————————————————————————– * Update White Flash Effect ————————————————————————–.
Methods inherited from Sprite_Base
#animation?, #animation_process_timing, #animation_set_sprites, #dispose_animation, #end_animation, #load_animation_bitmap, #make_animation_sprites, #set_animation_origin, #set_animation_rate, #start_animation, #update_animation
Constructor Details
#initialize(viewport, battler = nil) ⇒ Sprite_Battler
-
Object Initialization
16 17 18 19 20 21 22 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 16 def initialize(, battler = nil) super() @battler = battler @battler_visible = false @effect_type = nil @effect_duration = 0 end |
Instance Attribute Details
#battler ⇒ Object
-
Public Instance Variables
12 13 14 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 12 def battler @battler end |
Instance Method Details
#dispose ⇒ Object
-
Free
26 27 28 29 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 26 def dispose bitmap.dispose if bitmap super end |
#effect? ⇒ Boolean
-
Determine if Effect Is Executing
152 153 154 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 152 def effect? @effect_type != nil end |
#init_visibility ⇒ Object
-
Initialize Visibility
63 64 65 66 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 63 def init_visibility @battler_visible = @battler.alive? self.opacity = 0 unless @battler_visible end |
#revert_to_normal ⇒ Object
-
Revert to Normal Settings
131 132 133 134 135 136 137 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 131 def revert_to_normal self.blend_type = 0 self.color.set(0, 0, 0, 0) self.opacity = 255 self.ox = bitmap.width / 2 if bitmap self.src_rect.y = 0 end |
#setup_new_animation ⇒ Object
-
Set New Animation
141 142 143 144 145 146 147 148 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 141 def setup_new_animation if @battler.animation_id > 0 animation = $data_animations[@battler.animation_id] mirror = @battler.animation_mirror start_animation(animation, mirror) @battler.animation_id = 0 end end |
#setup_new_effect ⇒ Object
-
Set New Effect
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 87 def setup_new_effect if !@battler_visible && @battler.alive? start_effect(:appear) elsif @battler_visible && @battler.hidden? start_effect(:disappear) end if @battler_visible && @battler.sprite_effect_type start_effect(@battler.sprite_effect_type) @battler.sprite_effect_type = nil end end |
#start_effect(effect_type) ⇒ Object
-
Start Effect
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 101 def start_effect(effect_type) @effect_type = effect_type case @effect_type when :appear @effect_duration = 16 @battler_visible = true when :disappear @effect_duration = 32 @battler_visible = false when :whiten @effect_duration = 16 @battler_visible = true when :blink @effect_duration = 20 @battler_visible = true when :collapse @effect_duration = 48 @battler_visible = false when :boss_collapse @effect_duration = bitmap.height @battler_visible = false when :instant_collapse @effect_duration = 16 @battler_visible = false end revert_to_normal end |
#update ⇒ Object
-
Frame Update
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 33 def update super if @battler @use_sprite = @battler.use_sprite? if @use_sprite update_bitmap update_origin update_position end setup_new_effect setup_new_animation update_effect else self.bitmap = nil @effect_type = nil end end |
#update_appear ⇒ Object
-
Update Appearance Effect
196 197 198 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 196 def update_appear self.opacity = (16 - @effect_duration) * 16 end |
#update_bitmap ⇒ Object
-
Update Transfer Origin Bitmap
53 54 55 56 57 58 59 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 53 def update_bitmap new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue) if bitmap != new_bitmap self.bitmap = new_bitmap init_visibility end end |
#update_blink ⇒ Object
-
Update Blink Effect
190 191 192 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 190 def update_blink self.opacity = (@effect_duration % 10 < 5) ? 255 : 0 end |
#update_boss_collapse ⇒ Object
-
Update Boss Collapse Effect
216 217 218 219 220 221 222 223 224 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 216 def update_boss_collapse alpha = @effect_duration * 120 / bitmap.height self.ox = bitmap.width / 2 + @effect_duration % 2 * 4 - 2 self.blend_type = 1 self.color.set(255, 255, 255, 255 - alpha) self.opacity = alpha self.src_rect.y -= 1 Sound.play_boss_collapse2 if @effect_duration % 20 == 19 end |
#update_collapse ⇒ Object
-
Update Collapse Effect
208 209 210 211 212 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 208 def update_collapse self.blend_type = 1 self.color.set(255, 128, 128, 128) self.opacity = 256 - (48 - @effect_duration) * 6 end |
#update_disappear ⇒ Object
-
Updated Disappear Effect
202 203 204 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 202 def update_disappear self.opacity = 256 - (32 - @effect_duration) * 10 end |
#update_effect ⇒ Object
-
Update Effect
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 158 def update_effect if @effect_duration > 0 @effect_duration -= 1 case @effect_type when :whiten update_whiten when :blink update_blink when :appear update_appear when :disappear update_disappear when :collapse update_collapse when :boss_collapse update_boss_collapse when :instant_collapse update_instant_collapse end @effect_type = nil if @effect_duration == 0 end end |
#update_instant_collapse ⇒ Object
-
Update Instant Collapse Effect
228 229 230 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 228 def update_instant_collapse self.opacity = 0 end |
#update_origin ⇒ Object
-
Update Origin
70 71 72 73 74 75 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 70 def update_origin if bitmap self.ox = bitmap.width / 2 self.oy = bitmap.height end end |
#update_position ⇒ Object
-
Update Position
79 80 81 82 83 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 79 def update_position self.x = @battler.screen_x self.y = @battler.screen_y self.z = @battler.screen_z end |
#update_whiten ⇒ Object
-
Update White Flash Effect
183 184 185 186 |
# File 'lib/rgss3_default_scripts/Sprite_Battler.rb', line 183 def update_whiten self.color.set(255, 255, 255, 0) self.color.alpha = 128 - (16 - @effect_duration) * 10 end |