Project1
标题:
我找了好几个显示地名脚本都出现一样的问题
[打印本页]
作者:
晴天sama
时间:
2012-5-1 13:11
标题:
我找了好几个显示地名脚本都出现一样的问题
本帖最后由 晴天sama 于 2012-5-1 14:11 编辑
dsu_plus_rewardpost_czw
作者:
yychchhh
时间:
2012-5-1 15:33
本帖最后由 yychchhh 于 2012-5-1 15:33 编辑
解决了要选我为标准答案哦!
我就给你一条:
#==============================================================================
# 跳转地图时显示地图名 by 沉影不器
#------------------------------------------------------------------------------
# 功能: 在初进地图时,渐显地图名,随后渐隐
# 对于不需要显示地图名的地图,请在地图名里添加字符"@"
# 自定义各个地图名显示动画: 在地图名后加"_数字"
# 例: "戈壁_1"表示此地图显示的地图名为"戈壁",使用1号动画
#==============================================================================
# ■ Spriteset_Map
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ● 参数
#--------------------------------------------------------------------------
# 基本设定
MAX_OPACITY = 192 # 最大不透明度
SHOW_COUNT = 120 # 显示时间(均以帧为单位)
TRANS_COUNT = 60 # 渐变时间
NAME_WIN_WIDTH = 192 # 名称窗体宽度
NAME_WIN_HEIGHT = 56 # 名称窗体高度
# 美化选项
FONT_SIZE = 20 # 名称字体大小
FONT_COLOR = Color.new(255,255,255) # 名称字体颜色
FONT_SHADOW = true # 名称字体是否描绘阴影
SKIN = "Window" # 名称窗体自定义皮肤(空字符时隐藏窗体)
ANIMATION_ID = 0 # 显示名称时的动画 ID(0以下为无动画)
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
alias ini initialize
def initialize
# 获取地图名
name = get_map_name($game_map.map_id)
if $game_temp.old_map_name != name
$game_temp.old_map_name = name
unless name.include? "@"
create_name_window
end
end
ini
end
#--------------------------------------------------------------------------
# ○ 生成名窗体
#--------------------------------------------------------------------------
def create_name_window
# 初始化参数
@show_count = SHOW_COUNT
@trans_count_1 = TRANS_COUNT
@trans_count_2 = TRANS_COUNT
animation_id = get_animation_id($game_map.map_id)
animation_id = ANIMATION_ID if animation_id <= 0
# 显示动画
@name_animation = Sprite_Base.new(@viewport2)
@name_animation.x = Graphics.width/2
@name_animation.y = Graphics.height/2
if animation_id > 0
animation = $data_animations[animation_id]
if animation != nil
@name_animation.start_animation(animation)
else
p '指定动画不存在!'
end
end
x = (Graphics.width - NAME_WIN_WIDTH)/2
y = (Graphics.height - NAME_WIN_HEIGHT)/2
# 生成窗体
@name_window = Window_Base.new(x, y, NAME_WIN_WIDTH, NAME_WIN_HEIGHT)
@name_window.windowskin = Cache.system(SKIN)
@name_window.contents.font.size = FONT_SIZE
@name_window.contents.font.color = FONT_COLOR
@name_window.contents.font.shadow = FONT_SHADOW
@name_window.viewport = @viewport3
@name_window.opacity = 0
@name_window.contents_opacity = 0
# 地图名
text = $game_temp.old_map_name
@name_window.contents.draw_text(0,0,NAME_WIN_WIDTH-32,FONT_SIZE+4,text,1)
end
#--------------------------------------------------------------------------
# ○ 获取地图名
# map_id : 地图 ID
#--------------------------------------------------------------------------
def get_map_name(map_id)
mapinfo = load_data("Data/MapInfos.rvdata")
result = mapinfo[map_id].name
return result.split(/,/)[0].split(/_/)[0]
end
#--------------------------------------------------------------------------
# ○ 获取动画 ID
# map_id : 地图 ID
#--------------------------------------------------------------------------
def get_animation_id(map_id)
mapinfo = load_data("Data/MapInfos.rvdata")
result = mapinfo[map_id].name
return result.split(/,/)[0].split(/_/)[1].to_i
end
#--------------------------------------------------------------------------
# ○ 更新名窗体
#--------------------------------------------------------------------------
def update_name_window
return if @name_window == nil
# 已关闭时不需更新
return unless @name_window.visible
# 更新动画
@name_animation.update
# 渐现
if @trans_count_1 >= 0
@trans_count_1 -= 1
@name_window.opacity += MAX_OPACITY/TRANS_COUNT
@name_window.contents_opacity += MAX_OPACITY/TRANS_COUNT
end
# 显示时间计数
if @show_count >=0
@show_count -= 1
end
# 渐隐
if @show_count <= 0
if @trans_count_2 > 0
@trans_count_2 -= 1
@name_window.opacity -= MAX_OPACITY/TRANS_COUNT
@name_window.contents_opacity -= MAX_OPACITY/TRANS_COUNT
end
if @trans_count_2 <= 0
@name_window.visible = false
end
end
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
alias old_dispose dispose
def dispose
old_dispose
return if @name_window == nil
@name_window.dispose
@name_animation.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
alias old_update update
def update
old_update
update_name_window
end
end
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :old_map_name # 背景位图
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
alias ini initialize
def initialize
ini
@old_map_name = ""
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1