查看: 2503|回复: 3

[已经解决] 请问这个脚本◆显示文章怎么使用。。尴尬

[复制链接]
梦石
0
星屑
2457
在线时间
912 小时
注册时间
2014-10-14
回帖
1155

开拓者

发表于 2016-12-3 12:23:06 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
[pre lang="ruby"]#使用手冊!
#在Main 裏的14行增加 Mess_Text.ini
#
#==============================================================================
# ■ module Mess_Text
#------------------------------------------------------------------------------
#  在地图上显示文章的模块。
#==============================================================================
module Mess_Text
  MAX_LINE = 5  # 最大的行数
  MAX_TIME = 210 # 文字的维持时间
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def self.ini
    @text_sprite = Sprite.new
    @text_sprite.bitmap = Bitmap.new(350,290)
    @text_sprite.x = 10
    @text_sprite.y = 236 + 124
    @text_sprite.z = 100
    @line = 0
    @Time = MAX_TIME
  end
  #--------------------------------------------------------------------------
  # ● 设置可见度
  #--------------------------------------------------------------------------
  def self.visible=(v)
    @text_sprite.visible = v
  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)
    if @line >= MAX_LINE
      @text_sprite.bitmap.clear
      @line = 0
    end
    @text_sprite.bitmap.font.size = 16
    text_color(2)
    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
  #--------------------------------------------------------------------------
  # ● 获取文字色
  #     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[/pre]

点评

我认为可以做提示的 就是不知道怎么使用。。。尴尬中。。  发表于 2016-12-3 12:23
------落尽红樱君不见,轻绘梨花泪沾衣。~~~

梦石
0
星屑
9716
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-12-3 13:50:32 | 显示全部楼层
本帖最后由 cinderelmini 于 2016-12-3 13:54 编辑

唔、、除了代码框第二行说的在Main放个 Mess_Text.ini 之外,
大概还需要在Scene_Base的update里面再加一行
  1. Mess_Text.update
复制代码
然后在想要绘制文字的时候:
  1. Mess_Text.write("文本行1")
  2. Mess_Text.write("文本行2")
  3. Mess_Text.write("文本行3")
  4. ...
复制代码
这样执行。
PS:显示之后的文本会淡出但文本记录不会自己消除,下次调用 Mess_Text.write 的时候会往下一行加,
如果要清除之前显示的内容的话,在显示之前使用 Mess_Text.clear 清除一下记录。
PPAP:代码框21行和22行的格式→_→。。

点评

O(∩_∩)O谢谢 真尴尬 年龄越大越忘得快。。、  发表于 2016-12-3 14:23

评分

参与人数 2星屑 +230 收起 理由
RyanBern + 200 认可答案
j296196585 + 30 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部