Project1

标题: 在地图上显示文章 [打印本页]

作者: j296196585    时间: 2017-8-9 01:01
标题: 在地图上显示文章
本帖最后由 j296196585 于 2017-8-9 01:08 编辑

请问 为什么突然就不能用了呢
使用说明
Mess_Text.write("都做出了自己钟爱一生哒游戏啦")


自己脚本不全  。。

RUBY 代码复制
  1. #==============================================================================
  2. # ■ module Mess_Text
  3. #------------------------------------------------------------------------------
  4. #  在地图上显示文章的模块。
  5. #==============================================================================
  6. module Mess_Text
  7.   MAX_LINE = 30  # 最大的行数
  8.   MAX_TIME = 1000 # 文字的维持时间
  9.   #--------------------------------------------------------------------------
  10.   # ● 初始化
  11.   #--------------------------------------------------------------------------
  12.   def self.ini
  13.     @p = Sprite.new
  14.     @p.bitmap = Bitmap.new(900,600)
  15.     @p.bitmap.blt(0,0,RPG::Cache.picture("即时信息背景"),Rect.new(0,0,900,600))
  16.     @p.x = 640
  17.     @p.y = 0
  18.     @p.z += 999999
  19.     @text_sprite = Sprite.new
  20.     @text_sprite.bitmap = Bitmap.new(800,480)
  21.     @text_sprite.x = 650
  22.     @text_sprite.y = 8
  23.     @text_sprite.z += 1
  24.     @text_sprite.z += 999999
  25.     [url=home.php?mod=space&uid=401263]@line[/url] = 0
  26.     [url=home.php?mod=space&uid=134219]@Time[/url] = MAX_TIME
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # ● 设置可见度
  30.   #--------------------------------------------------------------------------
  31.   def self.visible=(v)
  32.     @text_sprite.visible = v
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 获取可见度
  36.   #--------------------------------------------------------------------------
  37.   def self.visible
  38.     return @text_sprite.disposed? ? false : @text_sprite.visible
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ● 释放
  42.   #--------------------------------------------------------------------------
  43.   def self.dispose
  44.     @text_sprite.dispose
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● 清空
  48.   #--------------------------------------------------------------------------
  49.   def self.clear
  50.     @text_sprite.bitmap.clear
  51.     @line = 0
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # ● 刷新
  55.   #--------------------------------------------------------------------------
  56.   def self.update
  57.     if @time > 0
  58.       @time -= 1
  59.     end
  60.     if @time <= 0 and @line > 0
  61.       @text_sprite.bitmap.clear
  62.       @line = 0
  63.     end
  64.   end
  65. =begin  
  66.   #--------------------------------------------------------------------------
  67.   # ● 刷新
  68.   #--------------------------------------------------------------------------
  69.   def self.write(str)
  70.     #$game_system.map_text.push(str)
  71.     x = 0
  72.     if @line >= MAX_LINE
  73.       @text_sprite.bitmap.clear
  74.       @line = 0
  75.     end
  76.     @text_sprite.bitmap.font.size = 16
  77.     # 有等待显示的文字的情况下
  78.     if str != nil
  79.       text = str.dup
  80.       # 限制文字处理
  81.       begin
  82.         last_text = text.clone
  83.         text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  84.       end until text == last_text
  85.       text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  86.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  87.       end
  88.       # 为了方便、将 "\\\\" 变换为 "\000"
  89.       text.gsub!(/\\\\/) { "\000" }
  90.       # "\\C" 变为 "\001" に、"\\G" 变为 "\002"
  91.       text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  92.       text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\002[#{$1}]" }
  93.       # "\P" 变为 "\003"
  94.       text.gsub!(/\\[Pp]/) { "\003" }
  95.       # c 获取 1 个字 (如果不能取得文字就循环)
  96.       while ((c = text.slice!(/./m)) != nil)
  97.         # \\ 的情况下
  98.         if c == "\000"
  99.           # 还原为本来的文字
  100.           c = "\\"
  101.         end
  102.         # \C[n] 的情况下
  103.         if c == "\001"
  104.           # 更改文字色
  105.           text.sub!(/\[([0-9]+)\]/, "")
  106.           color = $1.to_i
  107.           if color >= 0 and color <= 7
  108.             @text_sprite.bitmap.font.color = text_color(color)
  109.           end
  110.           # 下面的文字
  111.           next
  112.         end
  113.         # \S[n] 的情况下
  114.         if c == "\002"
  115.           # 更改字体大小
  116.           text.sub!(/\[([0-9]+)\]/, "")
  117.           size = $1.to_i
  118.           @text_sprite.bitmap.font.size = size
  119.         end
  120.         # 图片的情况下
  121.         if c == "\003"
  122.           pic_name = ''
  123.           while ((cha = text.slice!(/./m)) != ']')
  124.             next if cha == '['
  125.             pic_name += cha
  126.           end
  127.           pic = RPG::Cache.picture(pic_name)
  128.           @text_sprite.bitmap.blt(x + 4, @line * @text_sprite.bitmap.font.size, pic, Rect.new(0, 0, pic.width, pic.height))
  129.           x += pic.width
  130.           next
  131.         end
  132.         if x > 350-32
  133.           # y 加 1
  134.           @line += 1
  135.           x = 0
  136.           # 下面的文字
  137.           next
  138.         end
  139.         # 另起一行文字的情况下
  140.         if c == "\n"
  141.           # y 加 1
  142.           @line += 1
  143.           x = 0
  144.           # 下面的文字
  145.           next
  146.         end
  147.         # 描绘文字
  148.         @text_sprite.bitmap.draw_text(4 + x, @text_sprite.bitmap.font.size * @line, 40, 32, c)
  149.         # x 为要描绘文字的加法运算
  150.         x += @text_sprite.bitmap.text_size(c).width
  151.       end
  152.     end
  153.     @line += 1
  154.     @time = MAX_TIME
  155.   end
  156. =end
  157.   def self.write(str)
  158.     if @line >= MAX_LINE
  159.       @text_sprite.bitmap.clear
  160.       @line = 0
  161.     end
  162.     @text_sprite.bitmap.font.name = "宋体"
  163.     @text_sprite.bitmap.font.size = 13
  164.     @text_sprite.bitmap.font.color = Color.new(230, 200, 155, 255)
  165.     cw = @text_sprite.bitmap.text_size(str).width
  166.     @text_sprite.bitmap.draw_text_na(2, @line * (@text_sprite.bitmap.font.size + 2) + 5, cw, 20, str)
  167.     @line += 1
  168.     @time = MAX_TIME
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● 获取文字色
  172.   #     n : 文字色编号 (0~7)
  173.   #--------------------------------------------------------------------------
  174.   def self.text_color(n)
  175.     case n
  176.     when 0
  177.       return Color.new(255, 255, 255, 255)
  178.     when 1
  179.       return Color.new(128, 128, 255, 255)
  180.     when 2
  181.       return Color.new(255, 128, 128, 255)
  182.     when 3
  183.       return Color.new(128, 255, 128, 255)
  184.     when 4
  185.       return Color.new(128, 255, 255, 255)
  186.     when 5
  187.       return Color.new(255, 128, 255, 255)
  188.     when 6
  189.       return Color.new(255, 255, 128, 255)
  190.     when 7
  191.       return Color.new(192, 192, 192, 255)
  192.     else
  193.       normal_color
  194.     end
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # ● 获取普通文字色
  198.   #--------------------------------------------------------------------------
  199.   def self.normal_color
  200.     return Color.new(255, 255, 255, 255)
  201.   end
  202. end

360截图20170809010119221.jpg (31.82 KB, 下载次数: 0)

360截图20170809010119221.jpg

Project1.zip

498.48 KB, 下载次数: 37


作者: cinderelmini    时间: 2017-8-21 19:45
大概脚本缺了某些其他脚本的支持,
可以把出错的那行的“draw_text_na”改成“draw_text”,
如果有多处就再搜索一下“draw_text_na”,把全部都改了。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1