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

Project1

 找回密码
 注册会员
搜索

菜單教程的 if cn[0] == "[ DISCUZ_CODE_84 ]quot;

查看数: 1836 | 评论数: 1 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2015-4-12 01:01

正文摘要:

本帖最后由 lanlan1923 于 2015-4-12 01:04 编辑 https://rpg.blue/thread-323665-1-1.html 想請問這個教程裡的描繪選項的部分 RUBY 代码复制cn = $game_actors[@list[index ...

回复

VIPArcher 发表于 2015-4-12 01:18:15
本帖最后由 VIPArcher 于 2015-4-12 01:19 编辑

这个是老版本论坛代码解析带来的错误。
估计正确的是这样的
RUBY 代码复制
  1. class Window_NewMenuStatus < Window_Command
  2.   #----------------------------------------------------------------------------
  3.   # * 初始化
  4.   #----------------------------------------------------------------------------
  5.   def initialize
  6.     super(160, 0)
  7.   end
  8.   #----------------------------------------------------------------------------
  9.   # * 获取窗口的宽度
  10.   #----------------------------------------------------------------------------
  11.   def window_width
  12.     return 384
  13.   end
  14.   #----------------------------------------------------------------------------
  15.   # * 获取窗口的高度
  16.   #----------------------------------------------------------------------------
  17.   def window_height
  18.     return 416
  19.   end
  20.   #----------------------------------------------------------------------------
  21.   # * 更新内容
  22.   #----------------------------------------------------------------------------
  23.   def refresh
  24.     super
  25.     draw_actor_status
  26.   end
  27.   #----------------------------------------------------------------------------
  28.   # * 生成指令列表
  29.   #----------------------------------------------------------------------------
  30.   def make_command_list
  31.     for actor in $game_party.members
  32.       s = "a[#{actor.id}]"
  33.       add_command(actor.name, s.to_sym, !actor.death_state?, actor.id)
  34.     end
  35.   end
  36.   #----------------------------------------------------------------------------
  37.   # * 描绘选项
  38.   #----------------------------------------------------------------------------
  39.   def draw_item(index)
  40.     rect = item_rect_for_text(index)
  41.     b = Bitmap.new(rect.width, rect.height)
  42.     cn = $game_actors[@list[index][:ext]].character_name
  43.     ci = $game_actors[@list[index][:ext]].character_index
  44.     cb = Cache.character(cn)
  45.     if cn[0] == "$"
  46.       cr = Rect.new
  47.       cr.x = cb.width / 3
  48.       cr.width = cb.width / 3
  49.       cr.height = cb.height / 4
  50.     else
  51.       cr = Rect.new
  52.       cr.x = ci % 4 * (cb.width / 4) + cb.width / 12
  53.       cr.y = ci / 4 * (cb.height / 2)
  54.       cr.width = cb.width / 12
  55.       cr.height = cb.height / 8
  56.     end
  57.     b.blt((b.width - cr.width) / 2, (b.height - cr.height) / 2, cb, cr)
  58.     unless command_enabled?(index)
  59.       for y in 0...b.height
  60.         for x in 0...b.width
  61.           next if b.get_pixel(x, y).alpha == 0
  62.           c = b.get_pixel(x, y)
  63.           m = (c.red + c.green + c.blue) / 3
  64.           b.set_pixel(x, y, Color.new(m, m, m, c.alpha))
  65.         end
  66.       end
  67.     end
  68.     self.contents.blt(rect.x, rect.y, b, b.rect)
  69.     b.dispose
  70.     cb.dispose
  71.   end
  72.   #----------------------------------------------------------------------------
  73.   # * 获取项目的绘制矩形
  74.   #----------------------------------------------------------------------------
  75.   def item_rect(index)
  76.     rect = Rect.new
  77.     rect.width = self.contents.width / 4
  78.     rect.height = 48
  79.     rect.x = (index < 4 ? index * rect.width : (index - 4) * rect.width)
  80.     rect.y = (index < 4 ? 0 : self.contents.height - rect.height)
  81.     return rect
  82.   end
  83.   #----------------------------------------------------------------------------
  84.   # * 描绘角色的状态
  85.   #----------------------------------------------------------------------------
  86.   def draw_actor_status
  87.     actor = $game_actors[@list[@index][:ext]]
  88.     y = item_rect_for_text(0).height + 5
  89.     h = self.contents.height - 2 * (item_rect_for_text(0).height + 5)
  90.     self.contents.clear_rect(Rect.new(0, y, self.contents.width, h))
  91.     draw_actor_face(actor, 0, y)
  92.     draw_actor_name(actor, 0, y)
  93.     draw_actor_level(actor, 96, y)
  94.     draw_actor_nickname(actor, 168, y)
  95.     draw_actor_hp(actor, 96, y + line_height, self.contents.width - 96)
  96.     draw_actor_mp(actor, 96, y + 2 * line_height, self.contents.width - 96)
  97.     draw_actor_icons(actor, 96, y + 3 * line_height)
  98.     for i in 0...6
  99.       draw_actor_param(actor, 0, y + (4 + i) * line_height, i)
  100.     end
  101.     for i in 0...5
  102.       draw_item_name(actor.equips[i], self.contents.width / 2, y + (4 + i) * line_height) if actor.equips[i] != nil
  103.     end
  104.   end
  105.   #----------------------------------------------------------------------------
  106.   # * 选择项目
  107.   #----------------------------------------------------------------------------
  108.   def select(index)
  109.     super
  110.     draw_actor_status
  111.   end
  112. end

未测试

点评

正常了,謝謝!  发表于 2015-4-12 03:54

评分

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

查看全部评分

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

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

GMT+8, 2024-11-16 00:44

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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