Project1

标题: 怎么在装备上显示角色待机图 [打印本页]

作者: 没有马甲    时间: 2011-3-16 13:00
提示: 作者被禁止或删除 内容自动屏蔽
作者: originalgame    时间: 2011-3-16 16:27
沙发一下,等待解答
作者: 沙漠点灰    时间: 2011-3-16 17:47
把一下代码(紧接)插到Main前
  1. class Window_EquipLeft
  2.   alias dust_refresh refresh
  3.   def refresh
  4.     dust_refresh
  5.     draw_actor_graphic(@actor, 150, 48)
  6.   end
  7. end
复制代码
好了,测试一下吧
作者: 烁灵    时间: 2011-3-16 20:16
本帖最后由 烁灵 于 2011-3-16 20:17 编辑

记得从前柳柳前辈写过这个东西~
于是借用下沙漠前辈的代码咯~
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. # 作者: 柳柳
  5. #
  6. # 说明:这是功能我再比较早期的时候发布在幻森,不过那时候比较笨,方法很糟糕
  7. #       这次是拿上就可以用的。
  8. #
  9. # 感谢:Claimh的脚本使我想起这个功能重做了一遍,本想直接用他的,不过他的算法过分
  10. #       冗余了,没好意思用。
  11. #==============================================================================
  12. # 使用方法:默认情况下把静态图变为了走步图。如果想自行修改,提供功能如下:
  13. #
  14. # 角色走步图:draw_walk_actor_graphic
  15. # 角色转向图:draw_turn_actor_graphic
  16. #
  17. # 回复原有静态角色图:删除100行以后的内容。修改下面这个变量可以更改行走速度
  18. #==============================================================================

  19. WALK_REFRESH_FRAME_SPEED = 12  # 刷新的速度,越大越慢,你可以改为3左右试试看

  20. #==============================================================================
  21. # Window_Base
  22. #==============================================================================
  23. class Window_Base < Window
  24.   #--------------------------------------------------------------------------
  25.   # 初始化方法
  26.   #--------------------------------------------------------------------------
  27.   alias initialize_walk initialize
  28.   def initialize(x, y, width, height)
  29.     initialize_walk(x, y, width, height)
  30.     @start_walk = false
  31.     @turn_index = 0
  32.     @turn_phase = 0
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ★  角色行走图
  36.   #     actor : 角色
  37.   #     x     : 描绘的 X 坐标
  38.   #     y     : 描绘的 Y 坐标
  39.   #--------------------------------------------------------------------------
  40.   def draw_walk_actor_graphic(actor, x, y)
  41.     if actor.hp == 0
  42.       bitmap = RPG::Cache.character(actor.character_name+"_d", actor.character_hue)
  43.       cw = bitmap.width
  44.       ch = bitmap.height
  45.       src_rect = Rect.new(0,0,cw,ch)
  46.     else
  47.       bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  48.       cw = bitmap.width / 4
  49.       ch = bitmap.height / 4
  50.       @start_turn = true
  51.       case @turn_phase
  52.       when 0
  53.         x_x = 0
  54.       when 1
  55.         x_x = cw
  56.       when 2
  57.         x_x = cw * 2
  58.       when 3
  59.       x_x = cw * 3
  60.       end
  61.       src_rect = Rect.new(x_x, 0, cw, ch)
  62.     end
  63.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ★  角色转向图
  67.   #     actor : 角色
  68.   #     x     : 描绘的 X 坐标
  69.   #     y     : 描绘的 Y 坐标
  70.   #--------------------------------------------------------------------------
  71.   def draw_turn_actor_graphic(actor, x, y)
  72.     bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  73.     cw = bitmap.width / 4
  74.     ch = bitmap.height / 4
  75.     @start_turn = true
  76.     case @turn_phase
  77.     when 0
  78.       x_x = 0
  79.     when 1
  80.       x_x = ch
  81.     when 2
  82.       x_x = ch * 3
  83.     when 3
  84.       x_x = ch * 2
  85.     end
  86.     src_rect = Rect.new(0, x_x, cw, ch)
  87.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   #  更新(可别使用刷新,玩命耗费内存= =)
  91.   #--------------------------------------------------------------------------
  92.   alias walk_update update
  93.   def update
  94.     walk_update
  95.     if @start_turn == true
  96.       @turn_index += 1
  97.       if @turn_index == WALK_REFRESH_FRAME_SPEED
  98.         refresh
  99.         @turn_index = 0
  100.         @turn_phase = (@turn_phase+1)%4
  101.       end
  102.     end
  103.   end  
  104. end
  105. ###############################################################
  106. class Window_EquipLeft
  107.   alias dust_refresh refresh
  108.   def refresh
  109.     dust_refresh
  110.     draw_walk_actor_graphic(@actor, 150, 48)#原地踏步
  111.     #draw_turn_actor_graphic(@actor, 150, 48)#原地转圈
  112.   end
  113. end
  114. ###############################################################
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1