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

Project1

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

[已经解决] 任务脚本不显示字了。

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3065
在线时间
1429 小时
注册时间
2009-7-27
帖子
1448
跳转到指定楼层
1
发表于 2020-5-31 06:07:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
就是写了字,能接任务,但是任务内容却不显示。不知道是我设置问题还是脚本出错了。
以下是范例:
Project1.7z (189.46 KB, 下载次数: 38)

博客:我的博客

Lv3.寻梦者

梦石
0
星屑
2666
在线时间
383 小时
注册时间
2015-8-8
帖子
437

R考场第七期纪念奖

2
发表于 2020-5-31 16:06:24 | 只看该作者
本帖最后由 冷俊逸 于 2020-5-31 16:08 编辑

复制粘贴到源代码上,换行是\n不是直接回车。
258行那里改了下代码
  1. =begin
  2. --------------------------------------------------------------------------
  3. 详尽任务显示界面 v2.1
  4. --------------------------------------------------------------------------
  5. By 叶子

  6. 日期与更新
  7. 3-29-2006 -v1.0
  8. 4-3-2006  -v2.0
  9. -可以改变文字颜色,显示变量,显示图标,显示图片
  10. -大幅简化了编写任务内容的过程,加入自动换行功能
  11. -精简了窗口,使其还可以用作图鉴系统、日记系统等等
  12. 4-6-2006  -v2.1
  13. -增加了获得全部任务与删除全部任务命令
  14. -改正通假字,修改了示例任务3
  15. --------------------------------------------------------------------------
  16. 顾名思义,就是显示任务资料的界面
  17. 任务资料要预先在这里设定好
  18. 下载范例工程,能帮助你更快更好地掌握使用方法
  19. --------------------------------------------------------------------------
  20. 使用方法:

  21. 1、召唤任务显示界面:$scene = Scene_Task.new
  22. 2、领取任务:get_task(任务ID)

  23. 可以在事件中的“脚本”指令加入这段东西,又或者修改 Scene_Menu 来增加一个显示
  24. 任务的选项。如果是修改 Scene_Menu 增加选项的话,在脚本倒数第30行左右,
  25. 把 $scene = Scene_Map.new 修改成 $scene = Scene_Menu.new(任务界面index)

  26. 2、设置任务资料

  27.   2.1、相关内容解析
  28.   
  29.   所有内容文字必须用双引号括住
  30.   
  31.   名称:任务的名字(显示在左边窗口中),大小为208×32,如果全部为文字的话,
  32.         够放九个全角字符
  33.         
  34.   简介:任务的介绍(显示在右边窗口中),宽368,高不限
  35.   
  36.         文字可以自动换行
  37.   
  38.    2.1.1、控制码解析
  39.    
  40.    名称和内容均可用控制码,注意两条反斜线都要打!
  41.    
  42.    \\v[n] 显示n号变量
  43.    \\c[n] 改变字体颜色。
  44.           n=1~7 时同“显示文章”的\c[n],n=8 时为半透明色,n=9 时为系统色(青色)
  45.    \\n[i] 显示i号角色名字
  46.    \\i[文件名] 显示图标
  47.    \\p[文件名] 显示图片
  48.    
  49.    2.1.2、高级:内嵌表达式
  50.         
  51.    请参考帮助-脚本入门-字符串-内嵌表达式相关内容。
  52.    它可以用来在任务的名称和简介那里显示变量。
  53.    常用的表达式(注意不要漏了井号和大括号):
  54.    #{$game_variables[n]}       ——插入n号变量的值
  55.    #{$game_party.item_number(n)}  ——插入持有n号物品数量
  56.                                       同理还有weapon_number,armor_number
  57.    还可以预先定义一个变量,再插入(例子见示例任务3-灵魂线)
  58.    
  59.   2.2、注意事项
  60.   
  61.    2.2.1、括号、逗号和双引号 [ ] , " 必须使用半角符号(英文输入),
  62.           引号内的内容则没有关系
  63.          
  64.    2.2.2、单引号 ' 和双引号 " 的区别:
  65.           为了不出错误,全部用双引号吧!当然如果你对Ruby很熟悉,那就没所谓了
  66.   
  67.   2.3、开始设置吧!
  68.   从107行开始设置任务资料,可以参考示例任务来设置,请仔细阅读附加讲解
  69.   
  70. 3、接受任务

  71. 事件里的“脚本”指令输入:get_task(任务ID)
  72. 例如 get_task(1) 就是接受1号任务

  73.   3.1、获得全部任务
  74.   
  75.   事件里的“脚本”指令输入:get_all_task
  76.   这个功能基本上是用来在编写好所有任务资料后测试排版的
  77.   

  78. 4、完成/删除任务

  79. 事件里的“脚本”指令输入:finish_task(任务ID)
  80. 例如 finish_task(1) 就是完成1号任务

  81. 注意:本脚本不负责完成任务后的奖励之类的东西,请自行在事件中判断,
  82.        这里的完成任务指的是从任务列表中删去此任务

  83.   4.1、删除全部任务
  84.   
  85.   事件里的“脚本”指令输入:finish_all_task
  86.   作为获得全部任务的对应功能存在,似乎不会怎么用到
  87. =end

  88. class Scene_Task
  89.   # 这里设置任务内容翻页音效
  90.   CHANGE_PAGE_SE = "Audio/SE/046-Book01"
  91. end

  92. class Game_Party
  93.   #--------------------------------------------------------------------------
  94.   # ● 设置任务资料
  95.   #--------------------------------------------------------------------------
  96.   def get_tasks_info
  97.     @tasks_info = []
  98. 名称 = "变可爱啦倪"
  99. 简介 = "#{名称}:\n蛤♂乖乖站好"+
  100. "\n我也是一个广door人"+
  101. "\n去年勃起至今\n个个都是人才"

  102. @tasks_info[1] = Game_Task.new(名称, 简介)

  103. 名称 = ""
  104. 简介 = "
  105. "
  106. @tasks_info[2] = Game_Task.new(名称, 简介)
  107.    
  108.     #-----------------------------
  109.     # 示例任务3:灵魂线
  110.     #-----------------------------
  111.     #-讲解-
  112.     # 这里用了条件判断,当3号变量大于等于1时,加上“完成”字样,同时变色
  113.     #----
  114.     if $game_variables[3] >= 1
  115.       名称 = "\\c[8]灵魂线(完成)"
  116.       item = "\\c[8]灵魂线:#{$game_variables[3]}/1 (完成)"
  117.     else
  118.       名称 = "\\c[2]灵魂线"
  119.       item = "\\c[0]灵魂线:#{$game_variables[3]}/1"
  120.     end
  121.     #-讲解-
  122.     # 预先定义变量,用内嵌表达式插入
  123.     # 最后用了显示图标
  124.     #----
  125.     简介 = "#{名称}
  126.    
  127. \\c[9]任务目标:
  128. 找到埋起来的灵魂线,交给克萝莉亚

  129. #{item}

  130. \\c[0]克萝莉亚:
  131. 灵魂线就埋在其中一棵树下,给我好好找\\i[046-Skill03]"
  132.     @tasks_info[3] = Game_Task.new(名称, 简介)
  133.    
  134.   end
  135. end
  136.    
  137. #==============================================================================
  138. # ■ Interpreter
  139. #------------------------------------------------------------------------------
  140. #  执行事件命令的解释器。本类在 Game_System 类
  141. # 与 Game_Event 类的内部使用。
  142. #==============================================================================

  143. class Interpreter
  144.   #--------------------------------------------------------------------------
  145.   # ● 接受任务
  146.   #--------------------------------------------------------------------------
  147.   def get_task(id)
  148.     task = $game_party.tasks_info[id]
  149.     return true if (task.nil? or $game_party.current_tasks.include?(task.id))
  150.     $game_party.current_tasks.push(task.id)
  151.     return true
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # ● 获得全部任务
  155.   #--------------------------------------------------------------------------
  156.   def get_all_task
  157.     # 清空当前任务
  158.     $game_party.current_tasks.clear
  159.     for task in $game_party.tasks_info
  160.       next if task.nil?
  161.       $game_party.current_tasks.unshift(task.id)
  162.     end
  163.     return true
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 完成/放弃任务
  167.   #--------------------------------------------------------------------------
  168.   def finish_task(id)
  169.     task = $game_party.tasks_info[id]
  170.     return true if task.nil?
  171.     $game_party.current_tasks.delete(task.id)
  172.     return true
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # ● 删除全部任务
  176.   #--------------------------------------------------------------------------
  177.   def finish_all_task
  178.     $game_party.current_tasks.clear
  179.     return true
  180.   end
  181. end

  182. #==============================================================================
  183. # ■ Game_Party
  184. #------------------------------------------------------------------------------
  185. #  处理同伴的类。包含金钱以及物品的信息。本类的实例
  186. # 请参考 $game_party。
  187. #==============================================================================

  188. class Game_Party
  189.   #--------------------------------------------------------------------------
  190.   # ● 定义实例变量
  191.   #--------------------------------------------------------------------------
  192.   attr_writer     :latest_task                  # 上次查看的任务
  193.   #--------------------------------------------------------------------------
  194.   # ● 取得任务资料
  195.   #--------------------------------------------------------------------------
  196.   def tasks_info
  197.     if @tasks_info.nil?
  198.       get_tasks_info
  199.     end
  200.     return @tasks_info
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ● 取得当前任务
  204.   #--------------------------------------------------------------------------
  205.   def current_tasks
  206.     if @current_tasks.nil?
  207.       @current_tasks = []
  208.     end
  209.     return @current_tasks
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● 上次查看的任务
  213.   #--------------------------------------------------------------------------
  214.   def latest_task
  215.     if !current_tasks.include?(@latest_task)
  216.       @latest_task = current_tasks[0]
  217.     end
  218.     return @latest_task
  219.   end
  220. end

  221. #==============================================================================
  222. # ■ Game_Task
  223. #------------------------------------------------------------------------------
  224. #  处理任务的类。包含任务的信息。
  225. #==============================================================================

  226. class Game_Task
  227.   attr_accessor   :name                   # 名称
  228.   attr_accessor   :briefing               # 简介
  229.   def initialize(name, briefing)
  230.     @name = name
  231.     @briefing = briefing
  232.   end
  233.   def height
  234.     text = @briefing.clone
  235.     x = 0
  236.     y = 64
  237.     min_y = 0
  238.     # 限制文字处理
  239.     begin
  240.       last_text = text.clone
  241.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  242.     end until text == last_text
  243.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  244.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  245.     end
  246.     # 为了方便、将 "\\\\" 变换为 "\000"
  247.     text.gsub!(/\\\\/) { "\000" }
  248.     # "\C" 变为 "\001"
  249.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  250.     # "\I" 变为 "\002"
  251.     text.gsub!(/\\[Ii]/) { "\002" }
  252.     # "\P" 变为 "\003"
  253.     text.gsub!(/\\[Pp]/) { "\003" }
  254.     # c 获取 1 个字 (如果不能取得文字就循环)
  255.     while ((c = text.slice!(/./m)) != nil)
  256.       # \\ 的情况下
  257.       if c == "\000"
  258.         # 还原为本来的文字
  259.         c = "\\"
  260.       end
  261.       # \C[n] 的情况下
  262.       if c == "\001"
  263.         # 更改文字色
  264.         text.sub!(/\[([0-9]+)\]/, "")
  265.         # 下面的文字
  266.         next
  267.       end
  268.       # 图标的情况下
  269.       if c == "\002"
  270.         icon_name = ''
  271.         while ((cha = text.slice!(/./m)) != ']')
  272.           next if cha == '['
  273.           icon_name += cha
  274.         end
  275.         icon = RPG::Cache.icon(icon_name)
  276.         if x + icon.width > 368
  277.           x = 0
  278.           y += [32, min_y].max
  279.           min_y = 0
  280.         end
  281.         x += 28
  282.         next
  283.       end
  284.       # 图片的情况下
  285.       if c == "\003"
  286.         pic_name = ''
  287.         while ((cha = text.slice!(/./m)) != ']')
  288.           next if cha == '['
  289.           pic_name += cha
  290.         end
  291.         pic = RPG::Cache.picture(pic_name)
  292.         if x + pic.width > 368
  293.           x = 0
  294.           y += [32, min_y].max
  295.           min_y = 0
  296.         end
  297.         x += pic.width
  298.         min_y = [pic.height, 32].max
  299.         next
  300.       end
  301.       # 另起一行文字的情况下
  302.       if c == "\n"
  303.         y += [32, min_y].max
  304.         min_y = 0
  305.         x = 0
  306.         # 下面的文字
  307.         next
  308.       end
  309.       # 自动换行处理
  310.       if x + 22 > 368
  311.         y += [32, min_y].max
  312.         min_y = 0
  313.         x = 0
  314.       end
  315.       # x 为要描绘文字的加法运算
  316.       x += 22
  317.     end
  318.     return (y + [32, min_y].max)
  319.   end
  320.   def id
  321.     return $game_party.tasks_info.index(self)
  322.   end
  323. end

  324. #==============================================================================
  325. # ■ Window_Task_Name
  326. #------------------------------------------------------------------------------
  327. #  任务名称显示窗口。
  328. #==============================================================================

  329. class Window_Task_Name < Window_Selectable
  330.   #--------------------------------------------------------------------------
  331.   # ● 初始化对像
  332.   #--------------------------------------------------------------------------
  333.   def initialize(tasks)
  334.     super(0, 0, 160, 480)
  335.     @tasks = []
  336.     for id in tasks
  337.       @tasks.push($game_party.tasks_info[id])
  338.     end
  339.     @item_max = tasks.size
  340.     self.contents = Bitmap.new(
  341.     self.width - 32, @item_max == 0 ? 32 : @item_max * 32)
  342.     refresh
  343.     self.index = 0
  344.   end
  345.   #--------------------------------------------------------------------------
  346.   # ● 刷新
  347.   #--------------------------------------------------------------------------
  348.   def refresh
  349.     self.contents.clear
  350.     if @tasks != []
  351.       for task in @tasks
  352.         draw_item(task)
  353.       end
  354.     else
  355.       draw_blank
  356.     end
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # ● 描绘项目
  360.   #--------------------------------------------------------------------------
  361.   def draw_item(task)
  362.     text = task.name.clone
  363.     x = 0
  364.     y = @tasks.index(task) * 32
  365.     # 限制文字处理
  366.     begin
  367.       last_text = text.clone
  368.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  369.     end until text == last_text
  370.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  371.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  372.     end
  373.     # 为了方便、将 "\\\\" 变换为 "\000"
  374.     text.gsub!(/\\\\/) { "\000" }
  375.     # "\\C" 变为 "\001"
  376.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  377.     # "\I" 变为 "\002"
  378.     text.gsub!(/\\[Ii]/) { "\002" }
  379.     # "\P" 变为 "\003"
  380.     text.gsub!(/\\[Pp]/) { "\003" }
  381.     # c 获取 1 个字 (如果不能取得文字就循环)
  382.     while ((c = text.slice!(/./m)) != nil)
  383.       # \\ 的情况下
  384.       if c == "\000"
  385.         # 还原为本来的文字
  386.         c = "\\"
  387.       end
  388.       # \C[n] 的情况下
  389.       if c == "\001"
  390.         # 更改文字色
  391.         text.sub!(/\[([0-9]+)\]/, "")
  392.         color = $1.to_i
  393.         if color >= 0 and color <= 7
  394.           self.contents.font.color = text_color(color)
  395.         elsif color == 8
  396.           self.contents.font.color = disabled_color
  397.         elsif color == 9
  398.           self.contents.font.color = system_color
  399.         end
  400.         # 下面的文字
  401.         next
  402.       end
  403.       # 图标的情况下
  404.       if c == "\002"
  405.         icon_name = ''
  406.         while ((cha = text.slice!(/./m)) != ']')
  407.           next if cha == '['
  408.           icon_name += cha
  409.         end
  410.         icon = RPG::Cache.icon(icon_name)
  411.         if x + icon.width > self.contents.width
  412.           x = 0
  413.           y += [32, min_y].max
  414.           min_y = 0
  415.         end
  416.         self.contents.blt(x + 4, y + 4, icon, Rect.new(0, 0, 24, 24))
  417.         x += 28
  418.         next
  419.       end
  420.       # 图片的情况下
  421.       if c == "\003"
  422.         pic_name = ''
  423.         while ((cha = text.slice!(/./m)) != ']')
  424.           next if cha == '['
  425.           pic_name += cha
  426.         end
  427.         pic = RPG::Cache.picture(pic_name)
  428.         if x + pic.width > self.contents.width
  429.           x = 0
  430.           y += [32, min_y].max
  431.           min_y = 0
  432.         end
  433.         self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
  434.         x += pic.width
  435.         next
  436.       end
  437.       # 描绘文字
  438.       self.contents.draw_text(4 + x, y, 40, 32, c)
  439.       # x 为要描绘文字的加法运算
  440.       x += self.contents.text_size(c).width
  441.     end
  442.   end
  443.   #--------------------------------------------------------------------------
  444.   # ● 描绘空行
  445.   #--------------------------------------------------------------------------
  446.   def draw_blank
  447.     self.contents.font.color = disabled_color
  448.     rect = Rect.new(4, 0, self.contents.width - 8, 32)
  449.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  450.     self.contents.draw_text(rect, '暂无说明')
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # ● 获取任务
  454.   #--------------------------------------------------------------------------
  455.   def task
  456.     return @tasks[self.index]
  457.   end
  458. end
  459.   
  460. #==============================================================================
  461. # ■ Window_Task
  462. #------------------------------------------------------------------------------
  463. #  任务内容显示窗口。
  464. #==============================================================================

  465. class Window_Task < Window_Base
  466.   #--------------------------------------------------------------------------
  467.   # ● 初始化对像
  468.   #--------------------------------------------------------------------------
  469.   def initialize(task_id)
  470.     super(160, 0, 480, 480)
  471.     refresh(task_id)
  472.   end
  473.   #--------------------------------------------------------------------------
  474.   # ● 刷新内容
  475.   #--------------------------------------------------------------------------
  476.   def refresh(task_id)
  477.     self.oy = 0
  478.     self.visible = true
  479.     return if task_id.nil?
  480.     task = $game_party.tasks_info[task_id]
  481.     if !task.nil?
  482.       self.contents = Bitmap.new(self.width - 32, task.height)
  483.     else
  484.       self.contents = Bitmap.new(self.width - 32, self.height - 32)
  485.       return
  486.     end
  487.     self.contents.font.color = normal_color
  488.     # 描绘任务内容
  489.     draw_task_info(task)
  490.   end
  491.   #--------------------------------------------------------------------------
  492.   # ● 描绘任务内容
  493.   #--------------------------------------------------------------------------
  494.   def draw_task_info(task)
  495.     # 记录文字x坐标
  496.     x = 0
  497.     # 记录文字y坐标
  498.     y = 0
  499.     # 记录换行时y坐标最小加值
  500.     min_y = 0
  501.     self.contents.font.color = normal_color
  502.     # 描绘任务简介
  503.     text = task.briefing.clone
  504.     # 限制文字处理
  505.     begin
  506.       last_text = text.clone
  507.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  508.     end until text == last_text
  509.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  510.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  511.     end
  512.     # 为了方便、将 "\\\\" 变换为 "\000"
  513.     text.gsub!(/\\\\/) { "\000" }
  514.     # "\C" 变为 "\001"
  515.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  516.     # "\I" 变为 "\002"
  517.     text.gsub!(/\\[Ii]/) { "\002" }
  518.     # "\P" 变为 "\003"
  519.     text.gsub!(/\\[Pp]/) { "\003" }
  520.     # c 获取 1 个字 (如果不能取得文字就循环)
  521.     while ((c = text.slice!(/./m)) != nil)
  522.       # \\ 的情况下
  523.       if c == "\000"
  524.         # 还原为本来的文字
  525.         c = "\\"
  526.       end
  527.       # \C[n] 的情况下
  528.       if c == "\001"
  529.         # 更改文字色
  530.         text.sub!(/\[([0-9]+)\]/, "")
  531.         color = $1.to_i
  532.         if color >= 0 and color <= 7
  533.           self.contents.font.color = text_color(color)
  534.         elsif color == 8
  535.           self.contents.font.color = disabled_color
  536.         elsif color == 9
  537.           self.contents.font.color = system_color
  538.         end
  539.         # 下面的文字
  540.         next
  541.       end
  542.       # 图标的情况下
  543.       if c == "\002"
  544.         icon_name = ''
  545.         while ((cha = text.slice!(/./m)) != ']')
  546.           next if cha == '['
  547.           icon_name += cha
  548.         end
  549.         icon = RPG::Cache.icon(icon_name)
  550.         if x + icon.width > self.contents.width
  551.           x = 0
  552.           y += [32, min_y].max
  553.           min_y = 0
  554.         end
  555.         self.contents.blt(x + 4, y + 4, icon, Rect.new(0, 0, 24, 24))
  556.         x += 28
  557.         next
  558.       end
  559.       # 图片的情况下
  560.       if c == "\003"
  561.         pic_name = ''
  562.         while ((cha = text.slice!(/./m)) != ']')
  563.           next if cha == '['
  564.           pic_name += cha
  565.         end
  566.         pic = RPG::Cache.picture(pic_name)
  567.         if x + pic.width > self.contents.width
  568.           x = 0
  569.           y += [32, min_y].max
  570.           min_y = 0
  571.         end
  572.         self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
  573.         x += pic.width
  574.         min_y = [pic.height, 32].max
  575.         next
  576.       end
  577.       # 另起一行文字的情况下
  578.       if c == "\n"
  579.         y += [32, min_y].max
  580.         min_y = 0
  581.         x = 0
  582.         # 下面的文字
  583.         next
  584.       end
  585.       # 自动换行处理
  586.       if x + self.contents.text_size(c).width > self.contents.width
  587.         y += [32, min_y].max
  588.         min_y = 0
  589.         x = 0
  590.       end
  591.       # 描绘文字
  592.       self.contents.draw_text(4 + x, y, 40, 32, c)
  593.       # x 为要描绘文字的加法运算
  594.       x += self.contents.text_size(c).width
  595.     end
  596.   end
  597. end

  598. #==============================================================================
  599. # ■ Scene_Task
  600. #------------------------------------------------------------------------------
  601. #  处理任务画面的类。
  602. #==============================================================================

  603. class Scene_Task
  604.   #--------------------------------------------------------------------------
  605.   # ● 主处理
  606.   #--------------------------------------------------------------------------
  607.   def main
  608.     # 刷新任务资料
  609.     $game_party.get_tasks_info
  610.     # 生成任务名称窗口
  611.     @task_names_window = Window_Task_Name.new($game_party.current_tasks)
  612.     @task_names_window.active = true
  613.     if $game_party.current_tasks != []
  614.       @task_names_window.index = $game_party.current_tasks.index($game_party.latest_task)
  615.     end
  616.     # 生成任务内容窗口
  617.     @task_info_window = Window_Task.new($game_party.latest_task)
  618.     @task_info_window.active = true
  619.     # 执行过渡
  620.     Graphics.transition
  621.     # 主循环
  622.     loop do
  623.       # 刷新游戏画面
  624.       Graphics.update
  625.       # 刷新输入信息
  626.       Input.update
  627.       # 刷新画面
  628.       update
  629.       # 如果画面被切换的话就中断循环
  630.       if $scene != self
  631.         break
  632.       end
  633.     end
  634.     # 准备过渡
  635.     Graphics.freeze
  636.     # 释放窗口
  637.     @task_names_window.dispose
  638.     @task_info_window.dispose
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # ● 刷新画面
  642.   #--------------------------------------------------------------------------
  643.   def update
  644.     # 刷新窗口
  645.     @task_names_window.update
  646.     @task_info_window.update
  647.     update_task_names_window
  648.   end
  649.   #--------------------------------------------------------------------------
  650.   # ● 刷新任务名称窗口
  651.   #--------------------------------------------------------------------------
  652.   def update_task_names_window
  653.     # 按下 B 键的情况下
  654.     if Input.trigger?(Input::B)
  655.       # 演奏取消 SE
  656.       $game_system.se_play($data_system.cancel_se)
  657.       # 这里设置返回的场景,返回地图是Scene_Map.new,菜单是Scene_Menu.new(任务界面index)
  658.       $scene = Scene_Menu.new(4)
  659.       return
  660.     end
  661.     # 按下 C 键的情况下
  662.     if Input.trigger?(Input::C)
  663.       # 无任务可显示的话
  664.       if @task_names_window.task == nil
  665.         # 演奏冻结 SE
  666.         $game_system.se_play($data_system.buzzer_se)
  667.         return
  668.       end
  669.       # 如果光标没有移动的话,翻页
  670.       if $game_party.latest_task == @task_names_window.task.id
  671.         if @task_info_window.oy + @task_info_window.height - 32 > @task_info_window.contents.height
  672.           @task_info_window.oy = 0
  673.         else
  674.           @task_info_window.oy += 480-32
  675.         end
  676.         if @task_info_window.contents.height > @task_info_window.height - 32
  677.           # 演奏翻页 SE
  678.           Audio.se_play(CHANGE_PAGE_SE)
  679.         end
  680.       else
  681.         @task_info_window.refresh(@task_names_window.task.id)
  682.         $game_party.latest_task = @task_names_window.task.id
  683.         # 演奏确定 SE
  684.         $game_system.se_play($data_system.decision_se)
  685.       end
  686.     end
  687.   end
  688. end
复制代码

点评

真的欸!长知识了,是Ruby的语法糖吗  发表于 2020-6-1 21:58
谢谢,解决了。只是我发现可以直接换行,也不用后面加的+,双引号也只需要开头和结尾。  发表于 2020-6-1 18:29

评分

参与人数 1星屑 +50 收起 理由
RyanBern + 50 认可答案

查看全部评分

旧作《邵彦朝的大冒险》下载

默默无闻的论坛观察者
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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