设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2060|回复: 2
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

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

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

跳转到指定楼层
1
 楼主| 发表于 2013-2-28 21:05:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
要求如下:

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


操作流程:

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



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

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

Lv3.寻梦者 (版主)

八宝粥的基叔

梦石
0
星屑
4524
在线时间
5228 小时
注册时间
2009-4-29
帖子
14318

贵宾

来自 2楼
发表于 2013-3-1 17:00:13 | 只看该作者
本帖最后由 protosssonny 于 2013-9-19 09:20 编辑

二维数组什么的,头好晕。
还好,做了一个早上+一个中午,终于做完成了。
把成果发上来。
使用方法非常详细,看看就会用了,范例也做了。
真累,需要休息一下了。
小瞬.rar (243.07 KB, 下载次数: 32)
RUBY 代码复制
  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.  
  14.  
  15.   1、显示文章的方法,注意,这几行脚本必须写在同一脚本框内。
  16.      其中窗口号是几就写几,显示就写true,隐藏就写false,text用不理会照写即可
  17. #----------------------------------------------------
  18.   text =
  19.   "在这里输入文章即可显示
  20.   "
  21.   $scene::new_page(窗口号 ,显示或隐藏 ,text)
  22. #----------------------------------------------------
  23.  
  24.  
  25.   2、窗口刷新的方法。
  26.      其中窗口号是几就写几,显示就写true,隐藏就写false,X,Y坐标可以不写,不写
  27.      表示与上次窗口显示位置相同,写了的话会刷新窗口位置
  28. #----------------------------------------------------
  29.   $scene::am_refresh(窗口号 ,显示或隐藏 ,X坐标 ,Y坐标)
  30. #----------------------------------------------------
  31.  
  32.  
  33.   3、窗口隐藏的方法。
  34.      如果窗口不必要刷新,只是纯粹暂时不想显示,可以用以下命令更简便,当然你
  35.      调用1、2的方法,参数改为false来隐藏也没错。
  36. #----------------------------------------------------  
  37.   $scene::hide_am_window(窗口号)
  38. #----------------------------------------------------
  39.  
  40.  
  41.   3、窗口显示的方法。
  42.      如果窗口不必要刷新,只是纯粹暂时需要显示,可以用以下命令更简便,当然你
  43.      调用1、2的方法,参数改为true来隐藏也没错。
  44. #----------------------------------------------------  
  45.   $scene::show_am_window(窗口号)
  46. #----------------------------------------------------
  47.  
  48.  
  49.   ● 支持的特殊符号转换
  50.     \\V\[x]            显示x号变量
  51.     \\N\[x]            显示x号角色名称
  52.     \\C\[x]            文字变色
  53.     \\S\[x]            文字字号
  54.     \\I\[x]            图标号
  55.     \\\\               显示符号"\"
  56.  
  57. #------------------------------------------------------------------------------  
  58. =end
  59. #==============================================================================  
  60.  
  61. #==============================================================================
  62. # ■ Window_Gold
  63. #------------------------------------------------------------------------------
  64. #  显示金钱的窗口。
  65. #==============================================================================
  66.  
  67. class Window_Another_Message < Window_Base
  68.   #--------------------------------------------------------------------------
  69.   # ● 初始化对像
  70.   #     x      : 窗口 X 座标
  71.   #     y      : 窗口 Y 座标
  72.   #--------------------------------------------------------------------------
  73.   def initialize(x, y)
  74.     super(x, y, 544, WLH * 8 + 32)
  75.     @contents_x = 0              # 描绘下一字的 X 座标
  76.     @contents_y = 24             # 描绘下一字的 Y 座标
  77.     @line_count = 0              # 以描绘行数
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 新页处理(th——窗口号,text——文字)
  81.   #--------------------------------------------------------------------------
  82.   def new_page(text)
  83.     @save_text = text.dup
  84.     contents.clear
  85.     @contents_x = 0
  86.     @contents_y = 0
  87.     @line_count = 0
  88.     contents.font.color = text_color(0)
  89.     update_message(convert_special_characters(text))
  90.   end
  91.  
  92.   #--------------------------------------------------------------------------
  93.   # ● 新行处理
  94.   #--------------------------------------------------------------------------
  95.   def new_line
  96.     @contents_x = 0
  97.     @contents_y += WLH
  98.     @line_count += 1
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 转换特殊符号
  102.   #--------------------------------------------------------------------------
  103.   def convert_special_characters(text)
  104.     @text = text
  105.     @text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
  106.     @text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
  107.     @text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
  108.     @text.gsub!(/\\S\[([0-9]+)\]/i) { "\x02[#{$1}]" }
  109.     @text.gsub!(/\\I\[([0-9]+)\]/i) { "\x03[#{$1}]" }
  110.     @text.gsub!(/\\\\/)             { "\\" }
  111.     return @text
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 更新文章显示
  115.   #--------------------------------------------------------------------------
  116.   def update_message(text)
  117.     loop do
  118.       c = text.slice!(/./m)             # 获取一个文字
  119.       case c
  120.       when nil                          # 无法获取文字时
  121.         break
  122.       when "\n"                         # 新行
  123.         new_line
  124.       when "\x01"                       # \C[n](文字变色)
  125.         @text.sub!(/\[([0-9]+)\]/, "")
  126.         contents.font.color = text_color($1.to_i)
  127.         next  
  128.       when "\x02"                       # \S[n](文字字号)
  129.         @text.sub!(/\[([0-9]+)\]/, "")
  130.         contents.font.size = $1.to_i
  131.         next
  132.       when "\x03"                       # \I[n](图标)
  133.         @text.sub!(/\[([0-9]+)\]/, "")
  134.         draw_icon($1.to_i, @contents_x, @contents_y, true)
  135.         c_width = contents.text_size(c).width
  136.         @contents_x += 24
  137.       else
  138.         contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
  139.         c_width = contents.text_size(c).width
  140.         @contents_x += c_width  
  141.       end
  142.     end   
  143.   end
  144.  
  145.   def marshal_dump
  146.     [x, y, @save_text]
  147.   end
  148.   def marshal_load(data)
  149.     @x, @y, @save_text = data
  150.   end
  151.   def get_saved_data
  152.     return @x, @y, @save_text
  153.   end
  154.   attr_reader :save_text
  155. end
  156.  
  157. #==============================================================================
  158. # ■ Scene_Map
  159. #------------------------------------------------------------------------------
  160. #  处理地图画面的类。
  161. #==============================================================================
  162.  
  163.  
  164.  
  165. class Scene_Map < Scene_Base
  166.   #--------------------------------------------------------------------------
  167.   # ● 开始处理
  168.   #--------------------------------------------------------------------------
  169.   def start
  170.     super
  171.     $game_map.refresh
  172.     @spriteset = Spriteset_Map.new
  173.     @message_window = Window_Message.new
  174.     for th in W_V
  175.       $game_variables[th] = [nil, 0, 0, "", ""] unless $game_variables[th].is_a?(Array)
  176.       if $game_variables[th][0].nil?
  177.         $game_variables[th][0] = Window_Another_Message.new($game_variables[th][1],$game_variables[th][2])
  178.         $game_variables[th][0].opacity = 0
  179.       elsif $game_variables[th][0].disposed?
  180.         x, y, text = $game_variables[th][0].get_saved_data
  181.         $game_variables[th][0] = Window_Another_Message.new(x, y)
  182.         $game_variables[th][0].opacity = 0
  183.         $game_variables[th][0].new_page(text) if text
  184.       end
  185.     end  
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● 窗口刷新(th——窗口号,b——显示/隐藏,x——X坐标,y——Y坐标)
  189.   #--------------------------------------------------------------------------
  190.   def am_refresh(th, b, x = nil, y = nil)
  191.     $game_variables[W_V[th]][0].new_page($game_variables[W_V[th]][0].save_text)
  192.     $game_variables[W_V[th]][0].x = x if x
  193.     $game_variables[W_V[th]][0].y = y if y
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   # ● 显示新文字(th——窗口号,b——显示/隐藏,text——文字)
  197.   #--------------------------------------------------------------------------
  198.   def new_page(th ,b , text)
  199.     $game_variables[W_V[th]][0].new_page(text)
  200.     b == true ? show_am_window(th) : hide_am_window(th)
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ● 显示窗口(th——窗口号)
  204.   #--------------------------------------------------------------------------
  205.   def show_am_window(th)
  206.     $game_variables[W_V[th]][0].visible = true
  207.     return self
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ● 隐藏窗口(th——窗口号)
  211.   #--------------------------------------------------------------------------
  212.   def hide_am_window(th)
  213.     $game_variables[W_V[th]][0].visible = false
  214.     return self
  215.   end  
  216. 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
回复 支持 反对

使用道具 举报

Lv1.梦旅人

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

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

3
 楼主| 发表于 2013-3-1 17:37:44 | 只看该作者
受到了,谢谢小P孩

点评

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

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-28 02:28

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表