设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3203|回复: 2
打印 上一主题 下一主题

[已经过期] 修改地图名显示脚本,求改错

[复制链接]

Lv1.梦旅人

梦石
0
星屑
60
在线时间
317 小时
注册时间
2009-1-18
帖子
177
跳转到指定楼层
1
发表于 2012-4-23 20:05:16 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 Majirefy 于 2012-4-23 20:07 编辑

自己最近想稍微修改一下默认的地图名显示脚本,然后就有了这个:
  1. class Window_MapNamePlus < Window_Base
  2.   #--------------------------------------------------------------------------
  3.   # * 设置
  4.   #--------------------------------------------------------------------------
  5.   FONT_NAME   = ["PMingLiU", "FangSong"]    # 字体名称
  6.   FONT_SIZE   = 36                          # 字体大小
  7.   FONT_BOLD   = true                        # 字体是否加粗
  8.   FONT_COLOR  = Color.new(255, 255, 255, 0) # 字体颜色
  9.   FONT_OUT    = true                        # 字体是否加边框
  10.   OUT_COLOR   = Color.new(0, 0, 0, 0)       # 边框颜色
  11.   FONT_SHADOW = false                       # 字体是否有阴影
  12.   PADDING     = 12                          # 字体和窗口间距离
  13.   LINE_HEIGHT = 4                           # 分割线高度

  14.   #--------------------------------------------------------------------------
  15.   # * Object Initialization
  16.   #--------------------------------------------------------------------------
  17.   def initialize
  18.     #----------------------------------------------------------------------
  19.     # * Set the window in the middle of screen.
  20.     #----------------------------------------------------------------------
  21.     super(((Graphics.width - window_width) / 2),
  22.       ((Graphics.height - (FONT_SIZE + PADDING * 2)) / 2),
  23.       window_width, FONT_SIZE + PADDING * 2)
  24.     #----------------------------------------------------------------------
  25.     # * Custom font and style.
  26.     #----------------------------------------------------------------------
  27.     contents.font.name      = FONT_NAME
  28.     contents.font.size      = FONT_SIZE
  29.     contents.font.bold      = FONT_BOLD
  30.     contents.font.color     = FONT_COLOR
  31.     contents.font.outline   = FONT_OUT
  32.     contents.font.out_color = OUT_COLOR
  33.     contents.font.shadow    = FONT_SHADOW
  34.     #----------------------------------------------------------------------
  35.     # * Set Window Opacity
  36.     #----------------------------------------------------------------------
  37.     self.opacity = 0
  38.     self.contents_opacity = 0
  39.     @show_count = 0
  40.     refresh
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # * Get Window Width
  44.   #--------------------------------------------------------------------------
  45.   def window_width
  46.     return Graphics.width
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # * Frame Update
  50.   #--------------------------------------------------------------------------
  51.   def update
  52.     super
  53.     if @show_count > 0 && $game_map.name_display
  54.       update_fadein
  55.       @show_count -= 1
  56.     else
  57.       update_fadeout
  58.     end
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Update Fadein
  62.   #--------------------------------------------------------------------------
  63.   def update_fadein
  64.     self.contents_opacity += 16
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # * Update Fadeout
  68.   #--------------------------------------------------------------------------
  69.   def update_fadeout
  70.     self.contents_opacity -= 16
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # * Open Window
  74.   #--------------------------------------------------------------------------
  75.   def open
  76.     refresh
  77.     @show_count = 150
  78.     self.contents_opacity = 0
  79.     self
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Close Window
  83.   #--------------------------------------------------------------------------
  84.   def close
  85.     @show_count = 0
  86.     self
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # * Refresh
  90.   #--------------------------------------------------------------------------
  91.   def refresh
  92.     contents.clear
  93.     unless $game_map.display_name.empty?
  94.       p contents.rect
  95.       draw_line(contents.rect)
  96.       draw_text(contents.rect, $game_map.display_name, 1)
  97.     end
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # * Draw Line
  101.   #--------------------------------------------------------------------------
  102.   def draw_line(rect)
  103.     temp_rect = rect.clone
  104.     temp_rect.height = LINE_HEIGHT
  105.     temp_rect.width /= 2
  106.     contents.gradient_fill_rect(temp_rect, color2, color1)
  107.     temp_rect.x = temp_rect.width
  108.     contents.gradient_fill_rect(temp_rect, color1, color2)
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # * Get Color 1
  112.   #--------------------------------------------------------------------------
  113.   def color1
  114.     Color.new(255, 255, 255, 200)
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # * Get Color 2
  118.   #--------------------------------------------------------------------------
  119.   def color2
  120.     Color.new(255, 255, 255, 0)
  121.   end
  122. end
复制代码
但是插入后貌似没有达到预期的效果,预期的效果如下:

(灰色背景请无视,为了方便看的……)

这个运行后效果:

可以看到,文字没有描绘……
然后自己就不知道哪儿错了……
是refresh错了呢还是那儿呢?
另外,还是有些搞不懂contents中到底是什么,我知道是一个Bitmap,但是这个这个contents的一些属性(比如长度),我画分割线的时候,能做到随着我地图名字的改变而改变长度么?

点评

你不会在地图设置里的显示名称没有输入吧= =  发表于 2012-4-24 11:16

Lv1.梦旅人

Mr.Gandum

梦石
0
星屑
226
在线时间
2070 小时
注册时间
2007-1-31
帖子
3039

贵宾

2
发表于 2012-4-23 20:38:31 | 只看该作者
将contents.rect改为contents.text_size($game_map.display_name)试试。

点评

是draw_line里面的吗?修改了没有变化……(另外好奇某人的头像是谁……这个老头子好面熟……)  发表于 2012-4-23 21:01
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
317 小时
注册时间
2009-1-18
帖子
177
3
 楼主| 发表于 2012-4-24 12:18:07 | 只看该作者
本帖最后由 Majirefy 于 2012-4-24 12:27 编辑
feizhaodan 发表于 2012-4-23 20:38
将contents.rect改为contents.text_size($game_map.display_name)试试。


输入了啊………………………………这个问题还是不会犯错的………………{:2_253:}
而且如果是空的话,不是有判断么……不会显示的……


‘‘──Majirefy于2012-4-25 19:49补充以下内容

自己来回答吧……
检查了半天,发现在……在定义字体颜色FONT_COLOR和边框颜色OUT_COLOR的时候,透明度设置为了0…………………………
ORZ……
’’
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-10 11:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表