赞 | 0 |
VIP | 30 |
好人卡 | 0 |
积分 | 1 |
经验 | 16142 |
最后登录 | 2019-4-26 |
在线时间 | 317 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 60
- 在线时间
- 317 小时
- 注册时间
- 2009-1-18
- 帖子
- 177
|
本帖最后由 Majirefy 于 2012-4-23 20:07 编辑
自己最近想稍微修改一下默认的地图名显示脚本,然后就有了这个:- class Window_MapNamePlus < Window_Base
- #--------------------------------------------------------------------------
- # * 设置
- #--------------------------------------------------------------------------
- FONT_NAME = ["PMingLiU", "FangSong"] # 字体名称
- FONT_SIZE = 36 # 字体大小
- FONT_BOLD = true # 字体是否加粗
- FONT_COLOR = Color.new(255, 255, 255, 0) # 字体颜色
- FONT_OUT = true # 字体是否加边框
- OUT_COLOR = Color.new(0, 0, 0, 0) # 边框颜色
- FONT_SHADOW = false # 字体是否有阴影
- PADDING = 12 # 字体和窗口间距离
- LINE_HEIGHT = 4 # 分割线高度
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- #----------------------------------------------------------------------
- # * Set the window in the middle of screen.
- #----------------------------------------------------------------------
- super(((Graphics.width - window_width) / 2),
- ((Graphics.height - (FONT_SIZE + PADDING * 2)) / 2),
- window_width, FONT_SIZE + PADDING * 2)
- #----------------------------------------------------------------------
- # * Custom font and style.
- #----------------------------------------------------------------------
- contents.font.name = FONT_NAME
- contents.font.size = FONT_SIZE
- contents.font.bold = FONT_BOLD
- contents.font.color = FONT_COLOR
- contents.font.outline = FONT_OUT
- contents.font.out_color = OUT_COLOR
- contents.font.shadow = FONT_SHADOW
- #----------------------------------------------------------------------
- # * Set Window Opacity
- #----------------------------------------------------------------------
- self.opacity = 0
- self.contents_opacity = 0
- @show_count = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- if @show_count > 0 && $game_map.name_display
- update_fadein
- @show_count -= 1
- else
- update_fadeout
- end
- end
- #--------------------------------------------------------------------------
- # * Update Fadein
- #--------------------------------------------------------------------------
- def update_fadein
- self.contents_opacity += 16
- end
- #--------------------------------------------------------------------------
- # * Update Fadeout
- #--------------------------------------------------------------------------
- def update_fadeout
- self.contents_opacity -= 16
- end
- #--------------------------------------------------------------------------
- # * Open Window
- #--------------------------------------------------------------------------
- def open
- refresh
- @show_count = 150
- self.contents_opacity = 0
- self
- end
- #--------------------------------------------------------------------------
- # * Close Window
- #--------------------------------------------------------------------------
- def close
- @show_count = 0
- self
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- unless $game_map.display_name.empty?
- p contents.rect
- draw_line(contents.rect)
- draw_text(contents.rect, $game_map.display_name, 1)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Line
- #--------------------------------------------------------------------------
- def draw_line(rect)
- temp_rect = rect.clone
- temp_rect.height = LINE_HEIGHT
- temp_rect.width /= 2
- contents.gradient_fill_rect(temp_rect, color2, color1)
- temp_rect.x = temp_rect.width
- contents.gradient_fill_rect(temp_rect, color1, color2)
- end
- #--------------------------------------------------------------------------
- # * Get Color 1
- #--------------------------------------------------------------------------
- def color1
- Color.new(255, 255, 255, 200)
- end
- #--------------------------------------------------------------------------
- # * Get Color 2
- #--------------------------------------------------------------------------
- def color2
- Color.new(255, 255, 255, 0)
- end
- end
复制代码 但是插入后貌似没有达到预期的效果,预期的效果如下:
(灰色背景请无视,为了方便看的……)
这个运行后效果:
可以看到,文字没有描绘……
然后自己就不知道哪儿错了……
是refresh错了呢还是那儿呢?
另外,还是有些搞不懂contents中到底是什么,我知道是一个Bitmap,但是这个这个contents的一些属性(比如长度),我画分割线的时候,能做到随着我地图名字的改变而改变长度么? |
|