Naqqah Administrateur
Nombre de messages : 844 Age : 28 Localisation : Parti manger un ours Date d'inscription : 22/02/2009
| Sujet: [VX]Plusieurs couches pour le mapping ! Conseillé par Naqqah Sam 13 Fév - 12:55 | |
| Auteur : S. F. LaValle Fonction : Permet d'avoir plusieurs couches pour le mapping Image(s) : Installation : Allez dans l'éditeur de script, copiez le script et collez le au dessus de "Main" Utilisation : Faites une sous map ayant le même nom que la map mère mais en rajoutant L1. Si vous voulez faire plusieurs sous couches, faites la même opération mais rajoutez L2, L3 ...etc. Voir les images ci-dessous pour plus de compréhension Code : - Code:
-
class Scene_Map < Scene_Base
alias start_2 start
alias update_2 update
attr_reader :map_layer_spritesets
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
start_2
setup_map_layers
end
def update_transfer_player
return unless $game_player.transfer?
fade = (Graphics.brightness > 0)
fadeout(30) if fade
@spriteset.dispose # Dispose of sprite set
for i in 0...@map_layer_spritesets.size
@map_layer_spritesets[i].dispose
end
$game_player.perform_transfer # Execute player transfer
$game_map.autoplay # Automatically switch BGM and BGS
$game_map.update
Graphics.wait(15)
@spriteset = Spriteset_Map.new # Recreate sprite set
setup_map_layers
fadein(30) if fade
Input.update
end
def setup_map_layers
maps = load_data("Data/MapInfos.rvdata")
game_map_name = maps[$game_map.map_id].name
@map_layers = []
@map_layer_spritesets = []
map_names = []
layer_map_names = []
layer_index = []
c = maps.keys
d = c.max
for i in 1..d
unless maps[i] == nil
a = nil
map_names.push(maps[i].name)
a = maps[i].name =~ /(l|L)\d+/
layer_map_names.push(maps[i].name) if a != nil
layer_index.push(maps.index(maps[i])) if a != nil
end
end
for string in layer_map_names
string.chop! until string == game_map_name or string == ""# nil
end
if layer_map_names.include?(game_map_name)
for i in 0...layer_map_names.size
if layer_map_names[i] != ""
map = Game_Map.new
map.setup(layer_index[i])
@map_layer_spritesets.push(Spriteset_Map_2.new(map))
@map_layers.push(map)
end
end
end
end
def update
update_2
for i in 0...@map_layer_spritesets.size
@map_layers[i].update
@map_layer_spritesets[i].update
end
end
end
class Spriteset_Map_2 < Spriteset_Map
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(layer)
@layer = layer
create_viewports
create_tilemap
update
end
def update
update_tilemap
update_viewports
end
def dispose
@tilemap.dispose
end
#--------------------------------------------------------------------------
# * Create Tilemap
#--------------------------------------------------------------------------
def create_tilemap(a1 = nil, a2 = nil, a3 = nil, a4 = nil, a5 = nil, b = nil, c = nil, d = nil, e = nil)
@tilemap = Tilemap.new(@viewport1)
@tilemap.bitmaps[0] = (a1 == nil ? Cache.system("TileA1") : a1)
@tilemap.bitmaps[1] = (a2 == nil ? Cache.system("TileA2") : a2)
@tilemap.bitmaps[2] = (a3 == nil ? Cache.system("TileA3") : a3)
@tilemap.bitmaps[3] = (a4 == nil ? Cache.system("TileA4") : a4)
@tilemap.bitmaps[4] = (a5 == nil ? Cache.system("TileA5") : a5)
@tilemap.bitmaps[5] = (b == nil ? Cache.system("TileB") : b)
@tilemap.bitmaps[6] = (c == nil ? Cache.system("TileC") : c)
@tilemap.bitmaps[7] = (d == nil ? Cache.system("TileD") : d)
@tilemap.bitmaps[8] = (e == nil ? Cache.system("TileE") : e)
@tilemap.map_data = @layer.data
@tilemap.passages = @layer.passages
end
#--------------------------------------------------------------------------
# * Update Tilemap
#--------------------------------------------------------------------------
# def update_tilemap
# @tilemap.ox = @layer.display_x / 8
# @tilemap.oy = @layer.display_y / 8
# @tilemap.update
# end
#--------------------------------------------------------------------------
# * Update Viewport
#--------------------------------------------------------------------------
def update_viewports
@viewport1.tone = @layer.screen.tone
@viewport1.ox = @layer.screen.shake
@viewport2.color = @layer.screen.flash_color
@viewport3.color.set(0, 0, 0, 255 - @layer.screen.brightness)
@viewport1.update
@viewport2.update
@viewport3.update
end
end
Très simple à utiliser, efficace, conseillé par Naqqah. Merci beaucoup à RPG Creative | |
|