查看: 2616|回复: 2

[已经解决] 请人定制一枚显示文章的小脚本

[复制链接]

梦石
0
星屑
239
在线时间
2399 小时
注册时间
2008-4-11
回帖
11727

贵宾第6届短篇游戏比赛季军

发表于 2013-2-28 21:05:23 | 显示全部楼层 |阅读模式

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

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

×
要求如下:

1,能在屏幕中指定坐标显示文字和变量
2,文字可以使用和游戏中字体不同的字体
3,可以使用对话框的指令,比如\C[X]
4,文字瞬间显示,而不是像对话一样慢慢出来


操作流程:

在事件内插入两个变量
变量A代表坐标X
变量B代表坐标Y

QQ截图20130228134155.png

然后
打个比方用脚本来显示文字

$game_temp.map_string = "\\c[18] 史莱姆HP \\v[37]  最大HP \\v[41] "

八宝粥的基叔

梦石
0
星屑
4957
在线时间
5234 小时
注册时间
2009-4-29
回帖
14054

贵宾

发表于 2013-3-1 17:00:13 | 显示全部楼层
本帖最后由 protosssonny 于 2013-9-19 09:20 编辑

二维数组什么的,头好晕。
还好,做了一个早上+一个中午,终于做完成了。
把成果发上来。
使用方法非常详细,看看就会用了,范例也做了。
真累,需要休息一下了。
小瞬.rar (243.07 KB, 下载次数: 32)
  1. #==============================================================================
  2. # ■ P叔专门为小瞬制作的文章显示窗口
  3. #------------------------------------------------------------------------------
  4. # ● 初始设定
  5. # 请在下面输入控制三个窗口的变量,一旦该变量控制一个窗口,这个变量就不再具有
  6. # 变量的功能,除了调用窗口可以使用它意外,别的地方都不可以使用它。默认的控制
  7. # 变量为1、2、3号变量。第一个元素写0,不用理会。后面三个元素可以改,比如改成
  8. # [0,20,30,35]就表示20号变量控制第一个窗口,30号控制第二个,35号控制第三个。
  9.   W_V = [0,1,2,3]  # 第一个元素写0,不用理会。后面三个元素可以改。
  10. #------------------------------------------------------------------------------  
  11. =begin
  12.   ● 事件脚本控制命令


  13.   1、显示文章的方法,注意,这几行脚本必须写在同一脚本框内。
  14.      其中窗口号是几就写几,显示就写true,隐藏就写false,text用不理会照写即可
  15. #----------------------------------------------------
  16.   text =
  17.   "在这里输入文章即可显示
  18.   "
  19.   $scene::new_page(窗口号 ,显示或隐藏 ,text)
  20. #----------------------------------------------------

  21.   
  22.   2、窗口刷新的方法。
  23.      其中窗口号是几就写几,显示就写true,隐藏就写false,X,Y坐标可以不写,不写
  24.      表示与上次窗口显示位置相同,写了的话会刷新窗口位置
  25. #----------------------------------------------------
  26.   $scene::am_refresh(窗口号 ,显示或隐藏 ,X坐标 ,Y坐标)
  27. #----------------------------------------------------


  28.   3、窗口隐藏的方法。
  29.      如果窗口不必要刷新,只是纯粹暂时不想显示,可以用以下命令更简便,当然你
  30.      调用1、2的方法,参数改为false来隐藏也没错。
  31. #----------------------------------------------------  
  32.   $scene::hide_am_window(窗口号)
  33. #----------------------------------------------------


  34.   3、窗口显示的方法。
  35.      如果窗口不必要刷新,只是纯粹暂时需要显示,可以用以下命令更简便,当然你
  36.      调用1、2的方法,参数改为true来隐藏也没错。
  37. #----------------------------------------------------  
  38.   $scene::show_am_window(窗口号)
  39. #----------------------------------------------------


  40.   ● 支持的特殊符号转换
  41.     \\V\[x]            显示x号变量
  42.     \\N\[x]            显示x号角色名称
  43.     \\C\[x]            文字变色
  44.     \\S\[x]            文字字号
  45.     \\I\[x]            图标号
  46.     \\\\               显示符号""
  47.   
  48. #------------------------------------------------------------------------------  
  49. =end
  50. #==============================================================================  

  51. #==============================================================================
  52. # ■ Window_Gold
  53. #------------------------------------------------------------------------------
  54. #  显示金钱的窗口。
  55. #==============================================================================

  56. class Window_Another_Message < Window_Base
  57.   #--------------------------------------------------------------------------
  58.   # ● 初始化对像
  59.   #     x      : 窗口 X 座标
  60.   #     y      : 窗口 Y 座标
  61.   #--------------------------------------------------------------------------
  62.   def initialize(x, y)
  63.     super(x, y, 544, WLH * 8 + 32)
  64.     @contents_x = 0              # 描绘下一字的 X 座标
  65.     @contents_y = 24             # 描绘下一字的 Y 座标
  66.     @line_count = 0              # 以描绘行数
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● 新页处理(th——窗口号,text——文字)
  70.   #--------------------------------------------------------------------------
  71.   def new_page(text)
  72.     @save_text = text.dup
  73.     contents.clear
  74.     @contents_x = 0
  75.     @contents_y = 0
  76.     @line_count = 0
  77.     contents.font.color = text_color(0)
  78.     update_message(convert_special_characters(text))
  79.   end
  80.    
  81.   #--------------------------------------------------------------------------
  82.   # ● 新行处理
  83.   #--------------------------------------------------------------------------
  84.   def new_line
  85.     @contents_x = 0
  86.     @contents_y += WLH
  87.     @line_count += 1
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ● 转换特殊符号
  91.   #--------------------------------------------------------------------------
  92.   def convert_special_characters(text)
  93.     @text = text
  94.     @text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
  95.     @text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
  96.     @text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
  97.     @text.gsub!(/\\S\[([0-9]+)\]/i) { "\x02[#{$1}]" }
  98.     @text.gsub!(/\\I\[([0-9]+)\]/i) { "\x03[#{$1}]" }
  99.     @text.gsub!(/\\\\/)             { "\" }
  100.     return @text
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ● 更新文章显示
  104.   #--------------------------------------------------------------------------
  105.   def update_message(text)
  106.     loop do
  107.       c = text.slice!(/./m)             # 获取一个文字
  108.       case c
  109.       when nil                          # 无法获取文字时
  110.         break
  111.       when "\n"                         # 新行
  112.         new_line
  113.       when "\x01"                       # \C[n](文字变色)
  114.         @text.sub!(/\[([0-9]+)\]/, "")
  115.         contents.font.color = text_color($1.to_i)
  116.         next  
  117.       when "\x02"                       # \S[n](文字字号)
  118.         @text.sub!(/\[([0-9]+)\]/, "")
  119.         contents.font.size = $1.to_i
  120.         next
  121.       when "\x03"                       # \I[n](图标)
  122.         @text.sub!(/\[([0-9]+)\]/, "")
  123.         draw_icon($1.to_i, @contents_x, @contents_y, true)
  124.         c_width = contents.text_size(c).width
  125.         @contents_x += 24
  126.       else
  127.         contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
  128.         c_width = contents.text_size(c).width
  129.         @contents_x += c_width  
  130.       end
  131.     end   
  132.   end
  133.   
  134.   def marshal_dump
  135.     [x, y, @save_text]
  136.   end
  137.   def marshal_load(data)
  138.     @x, @y, @save_text = data
  139.   end
  140.   def get_saved_data
  141.     return @x, @y, @save_text
  142.   end
  143.   attr_reader :save_text
  144. end

  145. #==============================================================================
  146. # ■ Scene_Map
  147. #------------------------------------------------------------------------------
  148. #  处理地图画面的类。
  149. #==============================================================================



  150. class Scene_Map < Scene_Base
  151.   #--------------------------------------------------------------------------
  152.   # ● 开始处理
  153.   #--------------------------------------------------------------------------
  154.   def start
  155.     super
  156.     $game_map.refresh
  157.     @spriteset = Spriteset_Map.new
  158.     @message_window = Window_Message.new
  159.     for th in W_V
  160.       $game_variables[th] = [nil, 0, 0, "", ""] unless $game_variables[th].is_a?(Array)
  161.       if $game_variables[th][0].nil?
  162.         $game_variables[th][0] = Window_Another_Message.new($game_variables[th][1],$game_variables[th][2])
  163.         $game_variables[th][0].opacity = 0
  164.       elsif $game_variables[th][0].disposed?
  165.         x, y, text = $game_variables[th][0].get_saved_data
  166.         $game_variables[th][0] = Window_Another_Message.new(x, y)
  167.         $game_variables[th][0].opacity = 0
  168.         $game_variables[th][0].new_page(text) if text
  169.       end
  170.     end  
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # ● 窗口刷新(th——窗口号,b——显示/隐藏,x——X坐标,y——Y坐标)
  174.   #--------------------------------------------------------------------------
  175.   def am_refresh(th, b, x = nil, y = nil)
  176.     $game_variables[W_V[th]][0].new_page($game_variables[W_V[th]][0].save_text)
  177.     $game_variables[W_V[th]][0].x = x if x
  178.     $game_variables[W_V[th]][0].y = y if y
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # ● 显示新文字(th——窗口号,b——显示/隐藏,text——文字)
  182.   #--------------------------------------------------------------------------
  183.   def new_page(th ,b , text)
  184.     $game_variables[W_V[th]][0].new_page(text)
  185.     b == true ? show_am_window(th) : hide_am_window(th)
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● 显示窗口(th——窗口号)
  189.   #--------------------------------------------------------------------------
  190.   def show_am_window(th)
  191.     $game_variables[W_V[th]][0].visible = true
  192.     return self
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ● 隐藏窗口(th——窗口号)
  196.   #--------------------------------------------------------------------------
  197.   def hide_am_window(th)
  198.     $game_variables[W_V[th]][0].visible = false
  199.     return self
  200.   end  
  201. end  
复制代码

点评

表示我也吓尿了。。。  发表于 2013-3-2 18:06
怎么选择最佳答案?找不到啊  发表于 2013-3-2 06:22
吓尿了  发表于 2013-3-1 18:46

评分

参与人数 2星屑 +600 梦石 +1 收起 理由
Luciffer + 100 + 1 认可答案
一瞬间的幻觉 + 500 精品文章

查看全部评分

《逝去的回忆3:四叶草之梦》真情发布,欢迎点击图片下载试玩喵。

《逝去的回忆3》的讨论群:
一群:192885514
二群:200460747
回复

使用道具 举报

梦石
0
星屑
239
在线时间
2399 小时
注册时间
2008-4-11
回帖
11727

贵宾第6届短篇游戏比赛季军

 楼主| 发表于 2013-3-1 17:37:44 | 显示全部楼层
受到了,谢谢小P孩

点评

右下角:管理-置顶  发表于 2013-3-2 10:20
是P叔啊。会用了吗?  发表于 2013-3-1 17:38
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部