Home > RGSS Script Reference > Spriteset_Map
Spriteset_Map
Inherits from: None
Description: This class contains the set of sprites used in the Scene_Map class, such as the tileset, panorama, fog, weather, and pictures.
class Spriteset_Map
# ------------------------------------
def initialize
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 200
@viewport3.z = 5000
@tilemap = Tilemap.new(@viewport1)
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names[i]
@tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
@fog = Plane.new(@viewport1)
@fog.z = 3000
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
@weather = RPG::Weather.new(@viewport1)
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures[i]))
end
@timer_sprite = Sprite_Timer.new
update
end
# ------------------------------------
def dispose
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles[i].dispose
end
@tilemap.dispose
@panorama.dispose
@fog.dispose
for sprite in @character_sprites
sprite.dispose
end
@weather.dispose
for sprite in @picture_sprites
sprite.dispose
end
@timer_sprite.dispose
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
end
# ------------------------------------
def update
if @panorama_name != $game_map.panorama_name or
@panorama_hue != $game_map.panorama_hue
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
if @panorama.bitmap != nil
@panorama.bitmap.dispose
@panorama.bitmap = nil
end
if @panorama_name != ""
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
end
Graphics.frame_reset
end
if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
if @fog.bitmap != nil
@fog.bitmap.dispose
@fog.bitmap = nil
end
if @fog_name != ""
@fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
end
Graphics.frame_reset
end
@tilemap.ox = $game_map.display_x / 4
@tilemap.oy = $game_map.display_y / 4
@tilemap.update
@panorama.ox = $game_map.display_x / 8
@panorama.oy = $game_map.display_y / 8
@fog.zoom_x = $game_map.fog_zoom / 100.0
@fog.zoom_y = $game_map.fog_zoom / 100.0
@fog.opacity = $game_map.fog_opacity
@fog.blend_type = $game_map.fog_blend_type
@fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
@fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
@fog.tone = $game_map.fog_tone
for sprite in @character_sprites
sprite.update
end
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.ox = $game_map.display_x / 4
@weather.oy = $game_map.display_y / 4
@weather.update
for sprite in @picture_sprites
sprite.update
end
@timer_sprite.update
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
@viewport3.color = $game_screen.flash_color
@viewport1.update
@viewport3.update
end
end
|
Viewport1: The viewport for the panorama, fog, and character sprites.
Viewport2: The viewport for the pictures being shown on the screen.
Viewport3: The viewport for any "Flash Screen" effects being shown on the screen.
Tilemap: A Tilemap object representing the portion of the map tiles that can be seen in the viewport.
Panorama: The panorama sprite.
Fog: The fog sprite.
Character_Sprites: An array of Sprite_Character objects representing the event graphics on the map screen.
Weather: An RPG::Weather object that represents the weather effect sprite being shown on the screen.
Picture_Sprites: An array containing fiftySprite_Picture objects representing the pictures being shown on the screen.
Timer_Sprite: The Sprite_Timer object for the timer.
Initialize
Arguments: None
Local Variables: None
How it Works: This method initializes all the sprites in the spriteset. This class contains three viewports. Viewport #1 is the viewport for the fog, panorama, weather, and character sprites. Viewport #2 is the viewport for the picture sprites being shown on the screen. Viewport #3 is the viewport for any screen flash effect that might be taking place. First, the tilemap is set up and assigned to viewport #1. Within the tilemap, the seven autotiles are assigned to the array according to $game_map.autotile_names. The rest of the information, such as the priorities, counter flags, and obscuring tiles, are then loaded. The panorama is then assigned to viewport #1. and assigned a z-index of -1000, so that the tiles and characters will show above it. Then fog is then assigned to viewport #1, and assigned a z-index of 3000, so that it will show above the tiles and characters. For each event on the map, a Sprite_Character object is pushed onto the @sprite_character array. Each character sprite is assigned to viewport #1. The party leader's sprite is also pushed onto this array and assigned to viewport #1. Next, the weather sprite is set up and assigned to viewport #1. The fifty Sprite_Picture objects are then pushed onto the @sprite_pictures array and assigned to viewport #2. Finally, the timer sprite is set up, with no viewport assignment.
Dispose
Arguments: None
Local Variables: None
How it Works: The method calls the Sprite#Dispose method for each sprite in the spriteset.
Update
Arguments: None
Local Variables: None
How it Works: This class updates the spriteset each frame. It first checks to see whether the panorama name or hue modification has been changed as a result of a "Change Map Graphics" event command. If either has, then the panorama file and hue modification are updated to reflect those in $game_map.panorama_name and $game_map.panorama_hue, respectively. If the panorama is nil, because the map has no native panorama and the panorama has been removed, then the sprite is disposed of. If the map has a native panorama and the panoarama filename is "" (null string), then the map's native panorama is restored. The process is repeated for the fog graphic. If the fog name or hue has been changed, the fog graphic and hue modification are updated. If the map has no native fog graphic and the graphic is deleted, then the fog sprite is disposed of. Otherwise, the native fog graphic is reinstated. The rest of the method updates the various sprites' attributes, such as displacement, zoom, opacity.
|
|