赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 1313 |
最后登录 | 2012-11-18 |
在线时间 | 18 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 18 小时
- 注册时间
- 2009-9-17
- 帖子
- 29
|
3楼
楼主 |
发表于 2012-11-16 17:28:58
|
只看该作者
本帖最后由 Zale 于 2012-11-16 17:32 编辑
satgo1546 发表于 2012-11-16 17:18
请贴上脚本并用代码功能包含。
undefined method可能是脚本本身的bug也可能是脚本冲突引起的。前者没办法弄 ...
来自收录在置顶脚本库妖精图书馆里trentswd大大分享的地图名显示脚本:
http://rpg.blue/thread-100870-1-1.html- #▼▼▼区域,地图,地区名显示▼▼▼ by trentswd
- #-----------------------------------------------------------------------------
- # ● 常量
- #-----------------------------------------------------------------------------
- #▼地名窗口
- WIDTH = 150 # 窗口宽度最小值
- IN_TIME = 20 # 窗口出现时间
- SHOW_TIME = 60 # 窗口显示时间
- FADE_TIME = 30 # 窗口淡去时间
- TEXT1_SIZE = 19 # 地图名,区域名的字体大小
- TEXT2_SIZE = 13 # 地区名的字体大小
- TEXT1_COLOR = Color.new(255,255,255) # 地图名,区域名的默认颜色
- TEXT2_COLOR = Color.new(255,60,60) # 地区名的默认颜色
- SKIN = "red-grey" # 窗口皮肤的文件名
- VX_H = 416 # VX窗口高度
- VX_W = 544 # VX窗口宽度
- ZONE_NUM =8 # 地区名占用角色名的编号
- Map_W_S=1 # 控制是否显示的开关
- #▼地区名窗口
- Z_IN_TIME = 30 # 窗口出现时间
- Z_SHOW_TIME = 70 # 窗口显示时间
- Z_FADE_TIME = 30 # 窗口淡去时间
- ZONE_W_S=2 # 控制是否显示开关
- #▼计算
- HEIGHT = TEXT1_SIZE + TEXT2_SIZE + 34 # 窗口高度
- MWINDOW_Y = VX_H - HEIGHT - 16 # 窗口Y坐标
- #==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # 对Game_Map类的追加定义。
- #=============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # ● 获取所在场景名称
- #--------------------------------------------------------------------------
- def name
- load_data("Data/MapInfos.rvdata")
- end
- end
- #==============================================================================
- # ■ Map_Window
- #------------------------------------------------------------------------------
- # 游戏中显示地名的窗口。
- #=============================================================================
- class Map_Window<Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- super(-(5+WIDTH),MWINDOW_Y,WIDTH,HEIGHT)
- self.windowskin = Cache.system(SKIN)
- create_contents
- self.opacity = 255
- self.contents_opacity = 255
- self.contents.font.name=["华文细黑","STXihei","黑体"]
- @id=$game_map.map_id
- @time=0
- @a_id=$game_player.area_id
- @zone_change=false
- end
- #--------------------------------------------------------------------------
- # ● 覆盖定义contents(其实没有用囧)
- #--------------------------------------------------------------------------
- def create_contents
- self.contents.dispose
- self.contents = Bitmap.new(width-32, height-32)
- end
- #--------------------------------------------------------------------------
- # ● 地区标记为改变
- #--------------------------------------------------------------------------
- def zone_change
- @zone_change=true
- end
- #--------------------------------------------------------------------------
- # ● 得到地名
- #--------------------------------------------------------------------------
- def name(id=$game_map.map_id)
- name=$game_map.name[id].name.split(/@/)[0]
- return name
- end
- #--------------------------------------------------------------------------
- # ● 得到区域名
- #--------------------------------------------------------------------------
- def area_name(id=$game_player.area_id)
- name=$data_areas[id].name
- return name
- end
- #--------------------------------------------------------------------------
- # ● 得到地区名
- #--------------------------------------------------------------------------
- def zone(id=$game_map.map_id)
- name=$game_map.name[id].name.split(/@/)[1]
- return name
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if @a_id!=$game_player.area_id
- @a_id=$game_player.area_id
- if @a_id.is_a?(Numeric) && $game_switches[Map_W_S] == true
- self.width=[WIDTH,TEXT1_SIZE*self.name.size/3+50].max
- if @time==0
- self.x=-5-self.width
- end
- create_contents
- self.contents.font.size=TEXT1_SIZE
- self.contents.font.color=TEXT1_COLOR
- self.contents.draw_text(0,0,self.width-32,TEXT1_SIZE,self.area_name)
- self.contents.font.size=TEXT2_SIZE
- self.contents.font.color=TEXT2_COLOR
- self.contents.draw_text(0,TEXT1_SIZE+2,self.width-32,TEXT2_SIZE,$game_actors[ZONE_NUM].name)
- if @time==0
- @time=IN_TIME+SHOW_TIME+FADE_TIME
- elsif @time>SHOW_TIME+FADE_TIME
- @time=@time
- elsif @time>FADE_TIME
- @time=SHOW_TIME+FADE_TIME
- else
- @time=IN_TIME+(-self.width-5-self.x)/(self.width/IN_TIME)+SHOW_TIME+FADE_TIME
- end
- elsif $game_switches[Map_W_S] == true
- self.width=[WIDTH,TEXT1_SIZE*self.name.size/3+50].max
- if @time==0
- self.x=-5-self.width
- end
- create_contents
- self.contents.font.size=TEXT1_SIZE
- self.contents.font.color=TEXT1_COLOR
- self.contents.draw_text(0,0,self.width-32,TEXT1_SIZE,self.name)
- self.contents.font.size=TEXT2_SIZE
- self.contents.font.color=TEXT2_COLOR
- self.contents.draw_text(0,TEXT1_SIZE+2,self.width-32,TEXT2_SIZE,$game_actors[ZONE_NUM].name)
- if @time==0
- @time=IN_TIME+SHOW_TIME+FADE_TIME
- elsif @time>SHOW_TIME+FADE_TIME
- @time=time
- elsif @time>FADE_TIME
- @time=SHOW_TIME+FADE_TIME
- else
- @time=IN_TIME+(-self.width-5-self.x)/(self.width/IN_TIME)+SHOW_TIME+FADE_TIME
- end
- end
- end
- if @id!=$game_map.map_id
- self.contents.clear
- @id=$game_map.map_id
- if $game_switches[Map_W_S] == true
- if @zone_change == true
- if self.zone==nil
- else
- $game_actors[ZONE_NUM].name=self.zone
- end
- end
- self.width=[WIDTH,TEXT1_SIZE*self.name.size/3+50].max
- if @time==0
- self.x=-5-self.width
- end
- create_contents
- self.contents.font.size=TEXT1_SIZE
- self.contents.font.color=TEXT1_COLOR
- self.contents.draw_text(0,0,self.width-32,TEXT1_SIZE,self.name)
- self.contents.font.size=TEXT2_SIZE
- self.contents.font.color=TEXT2_COLOR
- self.contents.draw_text(0,TEXT1_SIZE+2,self.width-32,TEXT2_SIZE,$game_actors[ZONE_NUM].name)
- if @time==0
- @time=IN_TIME+SHOW_TIME+FADE_TIME
- elsif @time>SHOW_TIME+FADE_TIME
- @time=@time
- elsif @time>FADE_TIME
- @time=SHOW_TIME+FADE_TIME
- else
- @time=IN_TIME+(-self.width-5-self.x)/(self.width/IN_TIME)+SHOW_TIME+FADE_TIME
- end
- end
- end
- if @time>SHOW_TIME+FADE_TIME
- self.opacity = 255*(IN_TIME+SHOW_TIME+FADE_TIME-@time)/(IN_TIME-1)
- self.contents_opacity = 255*(IN_TIME+SHOW_TIME+FADE_TIME-@time)/(IN_TIME-1)
- self.x = -self.width-5+self.width*(IN_TIME+SHOW_TIME+FADE_TIME-@time)/(IN_TIME-1)
- @time-=1
- elsif @time>FADE_TIME
- @time-=1
- elsif @time>0
- self.opacity = 255*(@time-1)/(FADE_TIME-1)
- self.contents_opacity = 255*(@time-1)/(FADE_TIME-1)
- self.x = -self.width-5+self.width*(@time-1)/(FADE_TIME-1)
- @time-=1
- else
- self.opacity = 0
- self.contents_opacity = 0
- self.x = -self.width-5
- end
- end
- #--------------------------------------------------------------------------
- # ● 直接显示
- #--------------------------------------------------------------------------
- def d_display
- @time=IN_TIME+SHOW_TIME+FADE_TIME
- self.opacity = 0
- self.contents_opacity = 0
- self.x = -self.width-5
- end
- end
- #==============================================================================
- # ■ Game_Character
- #------------------------------------------------------------------------------
- # 判断当前人物所在区域id(by beside)。
- #=============================================================================
- class Game_Character
- def area_id
- for area in $data_areas.values
- if in_area?(area)
- return area.id
- end
- end
- end
- end
- #==============================================================================
- # ■ Scene_Map
- #------------------------------------------------------------------------------
- # 对Scene_Map的追加定义。
- #==============================================================================
- class Scene_Map < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始处理时建立对象
- #--------------------------------------------------------------------------
- alias _start start
- def start
- @map_window = Map_Window.new
- @zone_window = Zone_Window.new
- _start
- end
- #--------------------------------------------------------------------------
- # ● 释放时释放对象
- #--------------------------------------------------------------------------
- alias _terminate terminate
- def terminate
- @map_window.dispose
- @zone_window.dispose
- _terminate
- end
- #--------------------------------------------------------------------------
- # ● 刷新时刷新对象
- #--------------------------------------------------------------------------
- alias _update update
- def update
- @zone_window.refresh
- @map_window.refresh
- _update
- end
- #--------------------------------------------------------------------------
- # ● 标记为地区已改变(这个参数传递的很囧我承认)
- #--------------------------------------------------------------------------
- def zone_change
- @map_window.zone_change
- end
- end
- #==============================================================================
- # ■ Zone_Window
- #------------------------------------------------------------------------------
- # 显示地区名的类
- #=============================================================================
- class Zone_Window<Window_Base
- #--------------------------------------------------------------------------
- # ● 新建对象初始化
- #--------------------------------------------------------------------------
- def initialize
- super(0,0,50,50)
- create_contents
- self.opacity = 0
- self.contents_opacity = 0
- @time=0
- self.contents.font.shadow = false
- end
- #--------------------------------------------------------------------------
- # ● 直接显示
- #--------------------------------------------------------------------------
- def d_display
- @time=Z_IN_TIME+Z_SHOW_TIME+Z_FADE_TIME
- self.opacity = 0
- self.contents_opacity = 0
- self.x = -self.width-5
- end
- #--------------------------------------------------------------------------
- # ● 得到地区名
- #--------------------------------------------------------------------------
- def zone(id=$game_map.map_id)
- name=$game_map.name[id].name.split(/@/)[1]
- return name
- end
- #--------------------------------------------------------------------------
- # ● 得到地区英文名
- #--------------------------------------------------------------------------
- def zonee(id=$game_map.map_id)
- name=$game_map.name[id].name.split(/@/)[2]
- return name
- end
- #--------------------------------------------------------------------------
- # ● 描绘中文名
- #--------------------------------------------------------------------------
- def drawtext(x)
- self.contents.font.name=["华文中宋","STZhongsong","宋体","黑体"]
- self.contents.font.size=36
- self.contents.font.color=Color.new(255,255,255)
- self.contents.draw_text_f(x,0,self.contents.width,36,@text)
- end
- #--------------------------------------------------------------------------
- # ● 描绘英文名
- #--------------------------------------------------------------------------
- def drawtexten(x)
- self.contents.font.name=["Copperplate Gothic Light"]
- self.contents.font.size=12
- self.contents.font.color=Color.new(255,255,255)
- self.contents.draw_text_f(x,49,self.contents.width,12,@texten)
- end
- #--------------------------------------------------------------------------
- # ● 描绘横线
- #--------------------------------------------------------------------------
- def drawline
- self.contents.fill_rect(self.contents.width-5-@textw-1, 40, @textw+2, 5, Color.new(0,0,0,255))
- self.contents.fill_rect(self.contents.width-5-@textw, 41, @textw, 3, Color.new(255,255,255,255))
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.zone != $game_actors[ZONE_NUM].name && self.zone != "" && self.zone != nil
- $game_actors[ZONE_NUM].name=self.zone
- $scene.zone_change
- if $game_switches[ZONE_W_S] == true
- @text=self.zone
- @texten=self.zonee
- @[email protected]*36/3
- @[email protected]*6
- @textw=[@textl,@textenl].max+24
- @l=@textw/12
- self.x=VX_W-@textw-@textl-5-16
- self.y=0
- self.width=@textw+@textl+5+32
- self.height=32+12+12+36
- @time=Z_IN_TIME+Z_SHOW_TIME+Z_FADE_TIME
- create_contents
- end
- end
- if @time>Z_SHOW_TIME+Z_FADE_TIME
- self.contents_opacity = 255*(Z_IN_TIME+Z_SHOW_TIME+Z_FADE_TIME-@time)/(Z_IN_TIME-1)
- drawline
- if @time%2==1
- self.contents.clear
- drawline
- drawtext((self.contents.width-5-(@textw-@textl)/2-@textl)*(Z_IN_TIME+Z_SHOW_TIME+Z_FADE_TIME-@time)/(Z_IN_TIME-1))
- drawtexten(self.contents.width-(5+(@textw-@textenl)/2+@textenl)*(Z_IN_TIME+Z_SHOW_TIME+Z_FADE_TIME-@time)/(Z_IN_TIME-1))
- end
- @time-=1
- elsif @time>Z_FADE_TIME
- @time-=1
- elsif @time>0
- self.contents_opacity = 255*(@time-1)/(Z_FADE_TIME-1)
- if @time%2==1
- self.contents.clear
- drawline
- drawtext(self.contents.width-(5+(@textw-@textl)/2+@textl)*(@time-1)/(Z_FADE_TIME-1))
- drawtexten((self.contents.width-5-(@textw-@textenl)/2-@textenl)*(@time-1)/(Z_FADE_TIME-1))
- self.contents.blur
- end
- @time-=1
- else
- self.opacity=0
- self.contents_opacity=0
- end
- end
- end
- #==============================================================================
- # ◎ GPRA_Bitmap
- #------------------------------------------------------------------------------
- # ◎ Bitmap功能加强
- #------------------------------------------------------------------------------
- # 制作者:绿梨子红苹果
- # 个人主页:vbgm.9126.com
- # E-Mail:[email protected]
- # QQ:42378361
- #==============================================================================
- class Bitmap
- # 影子字
- def draw_text_s(x, y, width, height, str, align=0)
- # 保存当前颜色
- r=self.font.color.red
- g=self.font.color.green
- b=self.font.color.blue
- # 颜色更改成黑色
- self.font.color.set(0, 0, 0)
- # 绘制影子
- self.draw_text(x+2, y+2, width, height, str, align)
- # 恢复原始字色
- self.font.color.set(r,g,b)
- # 绘制原来的字
- self.draw_text(x, y, width, height, str, align)
- end
- # 描边字
- def draw_text_f(x, y, width, height, str, align=0)
- # 保存当前颜色
- r=self.font.color.red
- g=self.font.color.green
- b=self.font.color.blue
- # 颜色更改成黑色
- self.font.color.set(0, 0, 0)
- # 绘制边框
- self.draw_text(x-1, y-1, width, height, str, align)
- self.draw_text(x-1, y+1, width, height, str, align)
- self.draw_text(x+1, y-1, width, height, str, align)
- self.draw_text(x+1, y+1, width, height, str, align)
- self.draw_text(x, y-1, width, height, str, align)
- self.draw_text(x, y+1, width, height, str, align)
- self.draw_text(x-1, y, width, height, str, align)
- self.draw_text(x+1, y, width, height, str, align)
- # 恢复原始字色
- self.font.color.set(r,g,b)
- # 绘制原来的字
- self.draw_text(x, y, width, height, str, align)
- end
- end
复制代码 原帖里提供的范例下来运行正常,但是拷了他的系统图和脚本后到自己的作品后一开始游戏就弹出那个提示,不知缺漏了什么步骤T_T |
|