赞 | 0 |
VIP | 77 |
好人卡 | 306 |
积分 | 1 |
经验 | 85662 |
最后登录 | 2023-11-23 |
在线时间 | 1782 小时 |
Lv1.梦旅人 虱子
- 梦石
- 0
- 星屑
- 121
- 在线时间
- 1782 小时
- 注册时间
- 2010-6-19
- 帖子
- 3597
|
本帖最后由 Wind2010 于 2011-11-27 11:18 编辑
- #==============================================================================
- # ■ module Mess_Text
- #------------------------------------------------------------------------------
- # 在地图上显示文章的模块。
- #==============================================================================
- module Mess_Text
- MAX_LINE = 11 # 最大的行数
- MAX_TIME = 999 # 文字的维持时间
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def self.ini
- @text_sprite = Sprite.new
- @text_sprite.bitmap = Bitmap.new(350,190)
- @text_sprite.x = 32
- @text_sprite.y = 480-196
- @text_sprite.z = 10
- @beijing = Sprite.new
- @beijing.bitmap = Bitmap.new(350,190)
- @beijing.x = @text_sprite.x
- @beijing.y = @text_sprite.y
- @beijing.z = @text_sprite.z - 1
- @beijing.bitmap.fill_rect(0,0,350,190,Color.new(0,0,0,150))
- @beijing.opacity = 0
- @line = 0
- @time = MAX_TIME
- end
- #--------------------------------------------------------------------------
- # ● 设置可见度
- #--------------------------------------------------------------------------
- def self.visible=(v)
- @text_sprite.opacity = v
- @beijing.opacity = v == 255 ? 150 : 0
- end
- #--------------------------------------------------------------------------
- # ● 获取可见度
- #--------------------------------------------------------------------------
- def self.visible
- return @text_sprite.disposed? ? false : @text_sprite.visible
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def self.dispose
- @text_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # ● 清空
- #--------------------------------------------------------------------------
- def self.clear
- @text_sprite.bitmap.clear
- @line = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def self.update
- if @time > 0
- @time -= 1
- end
- if @time <= 0
- @text_sprite.bitmap.clear
- @line = 0
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def self.write(str)
- #$game_system.map_text.push(str)
- x = 0
- if @line >= MAX_LINE
- @text_sprite.bitmap.clear
- @line = 0
- end
- @text_sprite.bitmap.font.size = 16
- # 有等待显示的文字的情况下
- if str != nil
- text = str.dup
- # 限制文字处理
- begin
- last_text = text.clone
- text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
- end until text == last_text
- text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
- $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
- end
- # 为了方便、将 "\\\\" 变换为 "\000"
- text.gsub!(/\\\\/) { "\000" }
- # "\\C" 变为 "\001" に、"\\G" 变为 "\002"
- text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
- text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\002[#{$1}]" }
- # "\P" 变为 "\003"
- text.gsub!(/\\[Pp]/) { "\003" }
- # c 获取 1 个字 (如果不能取得文字就循环)
- while ((c = text.slice!(/./m)) != nil)
- # \\ 的情况下
- if c == "\000"
- # 还原为本来的文字
- c = "\\"
- end
- # \C[n] 的情况下
- if c == "\001"
- # 更改文字色
- text.sub!(/\[([0-9]+)\]/, "")
- color = $1.to_i
- if color >= 0 and color <= 7
- @text_sprite.bitmap.font.color = text_color(color)
- end
- # 下面的文字
- next
- end
- # \S[n] 的情况下
- if c == "\002"
- # 更改字体大小
- text.sub!(/\[([0-9]+)\]/, "")
- size = $1.to_i
- @text_sprite.bitmap.font.size = size
- end
- # 图片的情况下
- if c == "\003"
- pic_name = ''
- while ((cha = text.slice!(/./m)) != ']')
- next if cha == '['
- pic_name += cha
- end
- pic = RPG::Cache.picture(pic_name)
- @text_sprite.bitmap.blt(x + 4, @line * @text_sprite.bitmap.font.size, pic, Rect.new(0, 0, pic.width, pic.height))
- x += pic.width
- next
- end
- if x > 350-32
- # y 加 1
- @line += 1
- x = 0
- # 下面的文字
- next
- end
- # 另起一行文字的情况下
- if c == "\n"
- # y 加 1
- @line += 1
- x = 0
- # 下面的文字
- next
- end
- # 描绘文字
- @text_sprite.bitmap.draw_text(4 + x, @text_sprite.bitmap.font.size * @line, 40, 32, c)
- # x 为要描绘文字的加法运算
- x += @text_sprite.bitmap.text_size(c).width
- end
- end
- @line += 1
- @time = MAX_TIME
- end
- =begin
- def self.write(str)
- if @line >= MAX_LINE
- @text_sprite.bitmap.clear
- @line = 0
- end
- @text_sprite.bitmap.font.size = 16
- cw = @text_sprite.bitmap.text_size(str).width
- @text_sprite.bitmap.draw_text(0, @line * @text_sprite.bitmap.font.size, cw, 20, str)
- @line += 1
- @time = MAX_TIME
- end
- =end
- #--------------------------------------------------------------------------
- # ● 获取文字色
- # n : 文字色编号 (0~7)
- #--------------------------------------------------------------------------
- def self.text_color(n)
- case n
- when 0
- return Color.new(255, 255, 255, 255)
- when 1
- return Color.new(128, 128, 255, 255)
- when 2
- return Color.new(255, 128, 128, 255)
- when 3
- return Color.new(128, 255, 128, 255)
- when 4
- return Color.new(128, 255, 255, 255)
- when 5
- return Color.new(255, 128, 255, 255)
- when 6
- return Color.new(255, 255, 128, 255)
- when 7
- return Color.new(192, 192, 192, 255)
- else
- normal_color
- end
- end
- #--------------------------------------------------------------------------
- # ● 获取普通文字色
- #--------------------------------------------------------------------------
- def self.normal_color
- return Color.new(255, 255, 255, 255)
- end
- end
- class Scene_Title
- alias l_mes_main main unless defined?(l_mes_main)
- def main
- Mess_Text.clear
- l_mes_main
- end
- end
复制代码 目前这个脚本在写满了的时候会将文字清空后重新描述,如何让当文字满的时候再描绘的话是将最上面一条清除掉,剩下的往上移,然后再描绘?
自己改了下,虽然有字体问题我还是忍了,成功 |
|