本帖最后由 lanlan1923 于 2015-4-12 01:04 编辑 https://rpg.blue/thread-323665-1-1.html 想請問這個教程裡的描繪選項的部分 RUBY 代码复制cn = $game_actors[@list[index ...
class Window_NewMenuStatus < Window_Command #---------------------------------------------------------------------------- # * 初始化 #---------------------------------------------------------------------------- def initialize super(160, 0) end #---------------------------------------------------------------------------- # * 获取窗口的宽度 #---------------------------------------------------------------------------- def window_width return 384 end #---------------------------------------------------------------------------- # * 获取窗口的高度 #---------------------------------------------------------------------------- def window_height return 416 end #---------------------------------------------------------------------------- # * 更新内容 #---------------------------------------------------------------------------- def refresh super draw_actor_status end #---------------------------------------------------------------------------- # * 生成指令列表 #---------------------------------------------------------------------------- def make_command_list for actor in $game_party.members s = "a[#{actor.id}]" add_command(actor.name, s.to_sym, !actor.death_state?, actor.id) end end #---------------------------------------------------------------------------- # * 描绘选项 #---------------------------------------------------------------------------- def draw_item(index) rect = item_rect_for_text(index) b = Bitmap.new(rect.width, rect.height) cn = $game_actors[@list[index][:ext]].character_name ci = $game_actors[@list[index][:ext]].character_index cb = Cache.character(cn) if cn[0] == "$" cr = Rect.new cr.x = cb.width / 3 cr.width = cb.width / 3 cr.height = cb.height / 4 else cr = Rect.new cr.x = ci % 4 * (cb.width / 4) + cb.width / 12 cr.y = ci / 4 * (cb.height / 2) cr.width = cb.width / 12 cr.height = cb.height / 8 end b.blt((b.width - cr.width) / 2, (b.height - cr.height) / 2, cb, cr) unless command_enabled?(index) for y in 0...b.height for x in 0...b.width next if b.get_pixel(x, y).alpha == 0 c = b.get_pixel(x, y) m = (c.red + c.green + c.blue) / 3 b.set_pixel(x, y, Color.new(m, m, m, c.alpha)) end end end self.contents.blt(rect.x, rect.y, b, b.rect) b.dispose cb.dispose end #---------------------------------------------------------------------------- # * 获取项目的绘制矩形 #---------------------------------------------------------------------------- def item_rect(index) rect = Rect.new rect.width = self.contents.width / 4 rect.height = 48 rect.x = (index < 4 ? index * rect.width : (index - 4) * rect.width) rect.y = (index < 4 ? 0 : self.contents.height - rect.height) return rect end #---------------------------------------------------------------------------- # * 描绘角色的状态 #---------------------------------------------------------------------------- def draw_actor_status actor = $game_actors[@list[@index][:ext]] y = item_rect_for_text(0).height + 5 h = self.contents.height - 2 * (item_rect_for_text(0).height + 5) self.contents.clear_rect(Rect.new(0, y, self.contents.width, h)) draw_actor_face(actor, 0, y) draw_actor_name(actor, 0, y) draw_actor_level(actor, 96, y) draw_actor_nickname(actor, 168, y) draw_actor_hp(actor, 96, y + line_height, self.contents.width - 96) draw_actor_mp(actor, 96, y + 2 * line_height, self.contents.width - 96) draw_actor_icons(actor, 96, y + 3 * line_height) for i in 0...6 draw_actor_param(actor, 0, y + (4 + i) * line_height, i) end for i in 0...5 draw_item_name(actor.equips[i], self.contents.width / 2, y + (4 + i) * line_height) if actor.equips[i] != nil end end #---------------------------------------------------------------------------- # * 选择项目 #---------------------------------------------------------------------------- def select(index) super draw_actor_status endend
class Window_NewMenuStatus < Window_Command #---------------------------------------------------------------------------- # * 初始化 #---------------------------------------------------------------------------- def initialize super(160, 0) end #---------------------------------------------------------------------------- # * 获取窗口的宽度 #---------------------------------------------------------------------------- def window_width return 384 end #---------------------------------------------------------------------------- # * 获取窗口的高度 #---------------------------------------------------------------------------- def window_height return 416 end #---------------------------------------------------------------------------- # * 更新内容 #---------------------------------------------------------------------------- def refresh super draw_actor_status end #---------------------------------------------------------------------------- # * 生成指令列表 #---------------------------------------------------------------------------- def make_command_list for actor in $game_party.members s = "a[#{actor.id}]" add_command(actor.name, s.to_sym, !actor.death_state?, actor.id) end end #---------------------------------------------------------------------------- # * 描绘选项 #---------------------------------------------------------------------------- def draw_item(index) rect = item_rect_for_text(index) b = Bitmap.new(rect.width, rect.height) cn = $game_actors[@list[index][:ext]].character_name ci = $game_actors[@list[index][:ext]].character_index cb = Cache.character(cn) if cn[0] == "$" cr = Rect.new cr.x = cb.width / 3 cr.width = cb.width / 3 cr.height = cb.height / 4 else cr = Rect.new cr.x = ci % 4 * (cb.width / 4) + cb.width / 12 cr.y = ci / 4 * (cb.height / 2) cr.width = cb.width / 12 cr.height = cb.height / 8 end b.blt((b.width - cr.width) / 2, (b.height - cr.height) / 2, cb, cr) unless command_enabled?(index) for y in 0...b.height for x in 0...b.width next if b.get_pixel(x, y).alpha == 0 c = b.get_pixel(x, y) m = (c.red + c.green + c.blue) / 3 b.set_pixel(x, y, Color.new(m, m, m, c.alpha)) end end end self.contents.blt(rect.x, rect.y, b, b.rect) b.dispose cb.dispose end #---------------------------------------------------------------------------- # * 获取项目的绘制矩形 #---------------------------------------------------------------------------- def item_rect(index) rect = Rect.new rect.width = self.contents.width / 4 rect.height = 48 rect.x = (index < 4 ? index * rect.width : (index - 4) * rect.width) rect.y = (index < 4 ? 0 : self.contents.height - rect.height) return rect end #---------------------------------------------------------------------------- # * 描绘角色的状态 #---------------------------------------------------------------------------- def draw_actor_status actor = $game_actors[@list[@index][:ext]] y = item_rect_for_text(0).height + 5 h = self.contents.height - 2 * (item_rect_for_text(0).height + 5) self.contents.clear_rect(Rect.new(0, y, self.contents.width, h)) draw_actor_face(actor, 0, y) draw_actor_name(actor, 0, y) draw_actor_level(actor, 96, y) draw_actor_nickname(actor, 168, y) draw_actor_hp(actor, 96, y + line_height, self.contents.width - 96) draw_actor_mp(actor, 96, y + 2 * line_height, self.contents.width - 96) draw_actor_icons(actor, 96, y + 3 * line_height) for i in 0...6 draw_actor_param(actor, 0, y + (4 + i) * line_height, i) end for i in 0...5 draw_item_name(actor.equips[i], self.contents.width / 2, y + (4 + i) * line_height) if actor.equips[i] != nil end end #---------------------------------------------------------------------------- # * 选择项目 #---------------------------------------------------------------------------- def select(index) super draw_actor_status end end
查看全部评分
折叠内容标题(非必须)
折叠内容
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2024-11-16 00:44
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.