Project1
标题:
双远景优先级的问题,请大家帮忙
[打印本页]
作者:
闪电
时间:
2008-11-22 16:05
标题:
双远景优先级的问题,请大家帮忙
正常情况下:
放入NPC的情况:
在NPC下面的时候人物会自己跑到遮罩层上面
请问如何解决呢,谢谢 [LINE]1,#dddddd[/LINE]
版务信息:本贴由楼主自主结贴~
作者:
柳之一
时间:
2008-11-22 16:54
哈哈这个问题有人问了,请查阅主站的发布贴。
不想查也行,因为主角判定为在包厢的上面,直接无视遮罩层了。
在f1帮助有各个层的z坐标值,可以查阅。
至于宝箱,地图,遮罩和主角层级的关系,按照自己喜好调整就是了 [LINE]1,#dddddd[/LINE]
系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者:
hgfor
时间:
2008-11-22 20:11
Sprite_Character
#==============================================================================
# ■ Sprite_Character
#------------------------------------------------------------------------------
# 角色显示用脚本。监视 Game_Character 类的实例、
# 自动变化脚本状态。
#==============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :character # 角色
#--------------------------------------------------------------------------
# ● 初始化对像
# viewport : 查看端口
# character : 角色 (Game_Character)
#--------------------------------------------------------------------------
def initialize(viewport, character = nil)
super(viewport)
@character = character
update
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
# 元件 ID、文件名、色相与现在的情况存在差异的情况下
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# 记忆元件 ID 与文件名、色相
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# 元件 ID 为有效值的情况下
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# 元件 ID 为无效值的情况下
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
# 设置可视状态
self.visible = (not @character.transparent)
# 图形是角色的情况下
if @tile_id == 0
# 设置传送目标的矩形
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# 设置脚本的坐标
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
######################################
#與 雙遠景-偽優先級 腳本使用
#使用此腳本前要把所有@panorama2 换成 $panorama2
if @character.terrain_tag == 7
self.z = $panorama2.z + self.z
else
self.z = (-100 + self.z) > $panorama2.z ? ($panorama2.z - 1) : (-100 + self.z)
end
#####################################
# 设置不透明度、合成方式、茂密
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# 动画
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end
复制代码
双远景-伪-优先级
#==============================================================================
# 本脚本来自www.66rpg.com,使用前请参考制作录像
#==============================================================================
# ■ Spriteset_Map
#------------------------------------------------------------------------------
# 处理地图画面活动块和元件的类。本类在
# Scene_Map 类的内部使用。
#==============================================================================
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
$panorama2 = Plane.new(@viewport1)
$panorama2.z = 3000
# 生成雾平面
@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
$panorama2.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 abs(x)
if x < 0 # 如果 x 小于 0 的话,
return -x # 结束函数,返回值 -x。
else # 除此之外,
return x # 结束函数,返回值 x。
end # 分歧结束。
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
$panorama2.bitmap.dispose
$panorama2.bitmap = nil
@panarama.bitmap = nil
end
if @panorama_name != ""
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
$panorama2.bitmap = RPG::Cache.panorama(@panorama_name+"_2", @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 / 4
@panorama.oy = $game_map.display_y / 4
$panorama2.ox = @panorama.ox
$panorama2.oy = @panorama.oy
# 刷新雾平面
@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
#--------------------------------------------------------------------------------
# 雙遠景-偽優先級
#使用此腳本前要把所有@panorama2 换成 $panorama2
# 與隊伍/npc 遮擋修正
# width: 人物大約寛度, 越大修正範圍越多, 但可能卡
# 越小越順暢, 但視覺上會有點滯後
# 如人有1格寛,就應設做32,如此類推...
# height:人物大約高度,
# 如人有1格高,就應設做32,如此類推...
# *width不應比人物真實寛度大,否則可能造成與遮擋圖發生的問題
# By tintin
#--------------------------------------------------------------------------------
width = 20
height = 70
k = @character_sprites.size - 1
i = @character_sprites.size - 2
#case 隊尾/npc踏地圖元件7 方塊
#由隊尾檢查, 如隊尾不當遮擋隊頭, 修正隊頭
while i >= 0
#如事件/npc 圖片是"無"或角色透明 ,略過
if @character_sprites[i].re_char_name !="" && @character_sprites[i].re_char_transparent == false
j = i - 1
while j >= 0
#如事件/npc 圖片是"無"或角色透明,略過
if @character_sprites[j].re_char_name != "" && @character_sprites[j].re_char_transparent == false
if abs(@character_sprites[i].x - @character_sprites[j].x) < width &&
abs(@character_sprites[i].y - @character_sprites[j].y) < height &&
@character_sprites[i].y < @character_sprites[j].y &&
@character_sprites[i].z >= @character_sprites[j].z
@character_sprites[j].z = @character_sprites[i].z + 10
end
end
j-=1
end
#主角處理--@character_sprites[k]
if abs(@character_sprites[i].x - @character_sprites[k].x) < width &&
abs(@character_sprites[i].y - @character_sprites[k].y) < height &&
@character_sprites[i].y < @character_sprites[k].y &&
@character_sprites[i].z >= @character_sprites[k].z
@character_sprites[k].z = @character_sprites[i].z + 10
end
end
i-= 1
end
#case 隊頭踏地圖元件7 方塊
#由隊頭檢查, 如隊頭不當遮擋隊尾/npc, 修正隊尾
j = 0
#主角處理--@character_sprites[k]
while j <= @character_sprites.size - 2
if @character_sprites[j].re_char_name != "" && @character_sprites[j].re_char_transparent == false
if abs(@character_sprites[k].x - @character_sprites[j].x) < width &&
abs(@character_sprites[k].y - @character_sprites[j].y) < height &&
@character_sprites[k].y < @character_sprites[j].y &&
@character_sprites[k].z >= @character_sprites[j].z
@character_sprites[j].z = @character_sprites[k].z + 10
end
end
j+=1
end
i = 0
while i <= @character_sprites.size - 2
if @character_sprites[i].re_char_name != "" && @character_sprites[i].re_char_transparent == false
j = i + 1
while j <= @character_sprites.size - 2
if abs(@character_sprites[i].x - @character_sprites[j].x) <width &&
abs(@character_sprites[i].y - @character_sprites[j].y) <height &&
@character_sprites[i].y < @character_sprites[j].y &&
@character_sprites[i].z >= @character_sprites[j].z
@character_sprites[j].z = @character_sprites[i].z + 10
end
j+=1
end
end
i+= 1
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
#==============================================================================
# ■ Sprite_Character
#------------------------------------------------------------------------------
# 角色显示用脚本。监视 Game_Character 类的实例、
# 自动变化脚本状态。
#==============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# ● 取得角色 文件名
#--------------------------------------------------------------------------
def re_char_name
return @character.character_name
end
#--------------------------------------------------------------------------
# ● 取得透明状态
#--------------------------------------------------------------------------
def re_char_transparent
return @character.transparent
end
end
#==============================================================================
# 本脚本来自www.66rpg.com,使用前请参考制作录像
#==============================================================================
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1