Class: Spriteset_Battle
- Inherits:
-
Object
- Object
- Spriteset_Battle
- Defined in:
- lib/rgss3_default_scripts/Spriteset_Battle.rb
Overview
** Spriteset_Battle
This class brings together battle screen sprites. It's used within the
Scene_Battle class.
Instance Method Summary collapse
-
#animation? ⇒ Boolean
————————————————————————– * Determine if Animation is Being Displayed ————————————————————————–.
-
#autotile_type(z) ⇒ Object
————————————————————————– * Get Type of Auto Tile at Player’s Feet ————————————————————————–.
-
#battleback1_bitmap ⇒ Object
————————————————————————– * Get Battle Background (Floor) Bitmap ————————————————————————–.
-
#battleback1_name ⇒ Object
————————————————————————– * Get Filename of Battle Background (Floor) ————————————————————————–.
-
#battleback2_bitmap ⇒ Object
————————————————————————– * Get Battle Background (Wall) Bitmap ————————————————————————–.
-
#battleback2_name ⇒ Object
————————————————————————– * Get Filename of Battle Background (Wall) ————————————————————————–.
-
#battler_sprites ⇒ Object
————————————————————————– * Get Enemy and Actor Sprites ————————————————————————–.
-
#center_sprite(sprite) ⇒ Object
————————————————————————– * Move Sprite to Screen Center ————————————————————————–.
-
#create_actors ⇒ Object
————————————————————————– * Create Actor Sprite By default, the actor image is not displayed, but for convenience a dummy sprite is created for treating enemies and allies the same.
-
#create_battleback1 ⇒ Object
————————————————————————– * Create Battle Background (Floor) Sprite ————————————————————————–.
-
#create_battleback2 ⇒ Object
————————————————————————– * Create Battle Background (Wall) Sprite ————————————————————————–.
-
#create_blurry_background_bitmap ⇒ Object
————————————————————————– * Create Battle Background Bitmap from Processed Map Screen ————————————————————————–.
-
#create_enemies ⇒ Object
————————————————————————– * Create Enemy Sprite ————————————————————————–.
-
#create_pictures ⇒ Object
————————————————————————– * Create Picture Sprite Create an empty array in the initial state and then add to it as necessary.
-
#create_timer ⇒ Object
————————————————————————– * Create Timer Sprite ————————————————————————–.
-
#create_viewports ⇒ Object
————————————————————————– * Create Viewport ————————————————————————–.
-
#default_battleback1_name ⇒ Object
————————————————————————– * Get Filename of Default Battle Background (Floor) ————————————————————————–.
-
#default_battleback2_name ⇒ Object
————————————————————————– * Get Filename of Default Battle Background (Wall) ————————————————————————–.
-
#dispose ⇒ Object
————————————————————————– * Free ————————————————————————–.
-
#dispose_actors ⇒ Object
————————————————————————– * Free Actor Sprite ————————————————————————–.
-
#dispose_battleback1 ⇒ Object
————————————————————————– * Free Battle Background (Floor) Sprite ————————————————————————–.
-
#dispose_battleback2 ⇒ Object
————————————————————————– * Free Battle Background (Wall) Sprite ————————————————————————–.
-
#dispose_enemies ⇒ Object
————————————————————————– * Free Enemy Sprite ————————————————————————–.
-
#dispose_pictures ⇒ Object
————————————————————————– * Free Picture Sprite ————————————————————————–.
-
#dispose_timer ⇒ Object
————————————————————————– * Free Timer Sprite ————————————————————————–.
-
#dispose_viewports ⇒ Object
————————————————————————– * Free Viewport ————————————————————————–.
-
#effect? ⇒ Boolean
————————————————————————– * Determine if Effect Is Executing ————————————————————————–.
-
#initialize ⇒ Spriteset_Battle
constructor
————————————————————————– * Object Initialization ————————————————————————–.
-
#normal_battleback1_name ⇒ Object
————————————————————————– * Get Filename of Normal Battle Background (Floor) ————————————————————————–.
-
#normal_battleback2_name ⇒ Object
————————————————————————– * Get Filename of Normal Battle Background (Wall) ————————————————————————–.
-
#overworld_battleback1_name ⇒ Object
————————————————————————– * Get Filename of Field Battle Background (Floor) ————————————————————————–.
-
#overworld_battleback2_name ⇒ Object
————————————————————————– * Get Filename of Field Battle Background (Wall) ————————————————————————–.
-
#ship_battleback1_name ⇒ Object
————————————————————————– * Get Filename of Battle Background (Floor) When on Ship ————————————————————————–.
-
#ship_battleback2_name ⇒ Object
————————————————————————– * Get Filename of Battle Background (Wall) When on Ship ————————————————————————–.
-
#terrain_battleback1_name(type) ⇒ Object
————————————————————————– * Get Filename of Battle Background (Floor) Corresponding to Terrain ————————————————————————–.
-
#terrain_battleback2_name(type) ⇒ Object
————————————————————————– * Get Filename of Battle Background (Wall) Corresponding to Terrain ————————————————————————–.
-
#update ⇒ Object
————————————————————————– * Frame Update ————————————————————————–.
-
#update_actors ⇒ Object
————————————————————————– * Update Actor Sprite ————————————————————————–.
-
#update_battleback1 ⇒ Object
————————————————————————– * Update Battle Background (Floor) Sprite ————————————————————————–.
-
#update_battleback2 ⇒ Object
————————————————————————– * Update Battle Background (Wall) Sprite ————————————————————————–.
-
#update_enemies ⇒ Object
————————————————————————– * Update Enemy Sprite ————————————————————————–.
-
#update_pictures ⇒ Object
————————————————————————– *Update Picture Sprite ————————————————————————–.
-
#update_timer ⇒ Object
————————————————————————– * Update Timer Sprite ————————————————————————–.
-
#update_viewports ⇒ Object
————————————————————————– * Update Viewport ————————————————————————–.
Constructor Details
#initialize ⇒ Spriteset_Battle
-
Object Initialization
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 12 def initialize create_battleback1 create_battleback2 create_enemies create_actors create_pictures create_timer update end |
Instance Method Details
#animation? ⇒ Boolean
-
Determine if Animation is Being Displayed
380 381 382 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 380 def animation? battler_sprites.any? {|sprite| sprite.animation? } end |
#autotile_type(z) ⇒ Object
-
Get Type of Auto Tile at Player’s Feet
205 206 207 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 205 def autotile_type(z) $game_map.autotile_type($game_player.x, $game_player.y, z) end |
#battleback1_bitmap ⇒ Object
-
Get Battle Background (Floor) Bitmap
53 54 55 56 57 58 59 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 53 def battleback1_bitmap if battleback1_name Cache.battleback1(battleback1_name) else create_blurry_background_bitmap end end |
#battleback1_name ⇒ Object
-
Get Filename of Battle Background (Floor)
83 84 85 86 87 88 89 90 91 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 83 def battleback1_name if $BTEST $data_system.battleback1_name elsif $game_map.battleback1_name $game_map.battleback1_name elsif $game_map.overworld? overworld_battleback1_name end end |
#battleback2_bitmap ⇒ Object
-
Get Battle Background (Wall) Bitmap
63 64 65 66 67 68 69 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 63 def battleback2_bitmap if battleback2_name Cache.battleback2(battleback2_name) else Bitmap.new(1, 1) end end |
#battleback2_name ⇒ Object
-
Get Filename of Battle Background (Wall)
95 96 97 98 99 100 101 102 103 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 95 def battleback2_name if $BTEST $data_system.battleback2_name elsif $game_map.battleback2_name $game_map.battleback2_name elsif $game_map.overworld? overworld_battleback2_name end end |
#battler_sprites ⇒ Object
-
Get Enemy and Actor Sprites
374 375 376 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 374 def battler_sprites @enemy_sprites + @actor_sprites end |
#center_sprite(sprite) ⇒ Object
-
Move Sprite to Screen Center
211 212 213 214 215 216 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 211 def center_sprite(sprite) sprite.ox = sprite.bitmap.width / 2 sprite.oy = sprite.bitmap.height / 2 sprite.x = Graphics.width / 2 sprite.y = Graphics.height / 2 end |
#create_actors ⇒ Object
-
Create Actor Sprite
By default, the actor image is not displayed, but for convenience a dummy sprite is created for treating enemies and allies the same.
230 231 232 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 230 def create_actors @actor_sprites = Array.new(4) { Sprite_Battler.new(@viewport1) } end |
#create_battleback1 ⇒ Object
-
Create Battle Background (Floor) Sprite
35 36 37 38 39 40 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 35 def create_battleback1 @back1_sprite = Sprite.new(@viewport1) @back1_sprite.bitmap = battleback1_bitmap @back1_sprite.z = 0 center_sprite(@back1_sprite) end |
#create_battleback2 ⇒ Object
-
Create Battle Background (Wall) Sprite
44 45 46 47 48 49 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 44 def create_battleback2 @back2_sprite = Sprite.new(@viewport1) @back2_sprite.bitmap = battleback2_bitmap @back2_sprite.z = 1 center_sprite(@back2_sprite) end |
#create_blurry_background_bitmap ⇒ Object
-
Create Battle Background Bitmap from Processed Map Screen
73 74 75 76 77 78 79 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 73 def create_blurry_background_bitmap source = SceneManager.background_bitmap bitmap = Bitmap.new(640, 480) bitmap.stretch_blt(bitmap.rect, source, source.rect) bitmap.radial_blur(120, 16) bitmap end |
#create_enemies ⇒ Object
-
Create Enemy Sprite
220 221 222 223 224 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 220 def create_enemies @enemy_sprites = $game_troop.members.reverse.collect do |enemy| Sprite_Battler.new(@viewport1, enemy) end end |
#create_pictures ⇒ Object
-
Create Picture Sprite
Create an empty array in the initial state and then add to it as necessary.
238 239 240 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 238 def create_pictures @picture_sprites = [] end |
#create_timer ⇒ Object
-
Create Timer Sprite
244 245 246 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 244 def create_timer @timer_sprite = Sprite_Timer.new(@viewport2) end |
#create_viewports ⇒ Object
-
Create Viewport
25 26 27 28 29 30 31 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 25 def @viewport1 = Viewport.new @viewport2 = Viewport.new @viewport3 = Viewport.new @viewport2.z = 50 @viewport3.z = 100 end |
#default_battleback1_name ⇒ Object
-
Get Filename of Default Battle Background (Floor)
181 182 183 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 181 def default_battleback1_name "Grassland" end |
#default_battleback2_name ⇒ Object
-
Get Filename of Default Battle Background (Wall)
187 188 189 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 187 def default_battleback2_name "Grassland" end |
#dispose ⇒ Object
-
Free
250 251 252 253 254 255 256 257 258 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 250 def dispose dispose_battleback1 dispose_battleback2 dispose_enemies dispose_actors dispose_pictures dispose_timer end |
#dispose_actors ⇒ Object
-
Free Actor Sprite
282 283 284 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 282 def dispose_actors @actor_sprites.each {|sprite| sprite.dispose } end |
#dispose_battleback1 ⇒ Object
-
Free Battle Background (Floor) Sprite
262 263 264 265 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 262 def dispose_battleback1 @back1_sprite.bitmap.dispose @back1_sprite.dispose end |
#dispose_battleback2 ⇒ Object
-
Free Battle Background (Wall) Sprite
269 270 271 272 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 269 def dispose_battleback2 @back2_sprite.bitmap.dispose @back2_sprite.dispose end |
#dispose_enemies ⇒ Object
-
Free Enemy Sprite
276 277 278 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 276 def dispose_enemies @enemy_sprites.each {|sprite| sprite.dispose } end |
#dispose_pictures ⇒ Object
-
Free Picture Sprite
288 289 290 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 288 def dispose_pictures @picture_sprites.compact.each {|sprite| sprite.dispose } end |
#dispose_timer ⇒ Object
-
Free Timer Sprite
294 295 296 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 294 def dispose_timer @timer_sprite.dispose end |
#dispose_viewports ⇒ Object
-
Free Viewport
300 301 302 303 304 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 300 def @viewport1.dispose @viewport2.dispose @viewport3.dispose end |
#effect? ⇒ Boolean
-
Determine if Effect Is Executing
386 387 388 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 386 def effect? battler_sprites.any? {|sprite| sprite.effect? } end |
#normal_battleback1_name ⇒ Object
-
Get Filename of Normal Battle Background (Floor)
119 120 121 122 123 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 119 def normal_battleback1_name terrain_battleback1_name(autotile_type(1)) || terrain_battleback1_name(autotile_type(0)) || default_battleback1_name end |
#normal_battleback2_name ⇒ Object
-
Get Filename of Normal Battle Background (Wall)
127 128 129 130 131 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 127 def normal_battleback2_name terrain_battleback2_name(autotile_type(1)) || terrain_battleback2_name(autotile_type(0)) || default_battleback2_name end |
#overworld_battleback1_name ⇒ Object
-
Get Filename of Field Battle Background (Floor)
107 108 109 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 107 def overworld_battleback1_name $game_player.vehicle ? ship_battleback1_name : normal_battleback1_name end |
#overworld_battleback2_name ⇒ Object
-
Get Filename of Field Battle Background (Wall)
113 114 115 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 113 def overworld_battleback2_name $game_player.vehicle ? ship_battleback2_name : normal_battleback2_name end |
#ship_battleback1_name ⇒ Object
-
Get Filename of Battle Background (Floor) When on Ship
193 194 195 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 193 def ship_battleback1_name "Ship" end |
#ship_battleback2_name ⇒ Object
-
Get Filename of Battle Background (Wall) When on Ship
199 200 201 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 199 def ship_battleback2_name "Ship" end |
#terrain_battleback1_name(type) ⇒ Object
-
Get Filename of Battle Background (Floor) Corresponding to Terrain
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 135 def terrain_battleback1_name(type) case type when 24,25 # Wasteland "Wasteland" when 26,27 # Dirt field "DirtField" when 32,33 # Desert "Desert" when 34 # Rocks "Lava1" when 35 # Rocks (lava) "Lava2" when 40,41 # Snowfield "Snowfield" when 42 # Clouds "Clouds" when 4,5 # Poisonous swamp "PoisonSwamp" end end |
#terrain_battleback2_name(type) ⇒ Object
-
Get Filename of Battle Background (Wall) Corresponding to Terrain
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 158 def terrain_battleback2_name(type) case type when 20,21 # Forest "Forest1" when 22,30,38 # Low hill "Cliff" when 24,25,26,27 # Wasteland, dirt field "Wasteland" when 32,33 # Desert "Desert" when 34,35 # Rocks "Lava" when 40,41 # Snowfield "Snowfield" when 42 # Clouds "Clouds" when 4,5 # Poisonous swamp "PoisonSwamp" end end |
#update ⇒ Object
-
Frame Update
308 309 310 311 312 313 314 315 316 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 308 def update update_battleback1 update_battleback2 update_enemies update_actors update_pictures update_timer end |
#update_actors ⇒ Object
-
Update Actor Sprite
338 339 340 341 342 343 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 338 def update_actors @actor_sprites.each_with_index do |sprite, i| sprite.battler = $game_party.members[i] sprite.update end end |
#update_battleback1 ⇒ Object
-
Update Battle Background (Floor) Sprite
320 321 322 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 320 def update_battleback1 @back1_sprite.update end |
#update_battleback2 ⇒ Object
-
Update Battle Background (Wall) Sprite
326 327 328 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 326 def update_battleback2 @back2_sprite.update end |
#update_enemies ⇒ Object
-
Update Enemy Sprite
332 333 334 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 332 def update_enemies @enemy_sprites.each {|sprite| sprite.update } end |
#update_pictures ⇒ Object
*Update Picture Sprite
347 348 349 350 351 352 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 347 def update_pictures $game_troop.screen.pictures.each do |pic| @picture_sprites[pic.number] ||= Sprite_Picture.new(@viewport2, pic) @picture_sprites[pic.number].update end end |
#update_timer ⇒ Object
-
Update Timer Sprite
356 357 358 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 356 def update_timer @timer_sprite.update end |
#update_viewports ⇒ Object
-
Update Viewport
362 363 364 365 366 367 368 369 370 |
# File 'lib/rgss3_default_scripts/Spriteset_Battle.rb', line 362 def @viewport1.tone.set($game_troop.screen.tone) @viewport1.ox = $game_troop.screen.shake @viewport2.color.set($game_troop.screen.flash_color) @viewport3.color.set(0, 0, 0, 255 - $game_troop.screen.brightness) @viewport1.update @viewport2.update @viewport3.update end |