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

Project1

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

[已经过期] 行走图多帧

[复制链接]

Lv1.梦旅人

梦石
0
星屑
87
在线时间
39 小时
注册时间
2012-8-15
帖子
26
跳转到指定楼层
1
发表于 2014-1-19 06:51:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
xp的默认行走图是4*4的。但我的人物大一些,4*4要损画质的。
能不能把行走图变成4*8甚至4*12的?

Lv3.寻梦者

梦石
0
星屑
3841
在线时间
1966 小时
注册时间
2013-1-3
帖子
9536
2
发表于 2014-1-19 08:50:17 | 只看该作者
  1. ###########################################################################################################################
  2. # 脚本功能:八方向走与多帧移动之图片修正 + 人物跟随。

  3. # 更新日期:2005年8月6日

  4. # 更新内容:增加斜方向触发,增加斜方向面向角色(1步之内)

  5. # 使用方法:将本脚本插入到main之前。如果你使用了雅土版的八方向走脚本,请确保这个脚本的顺序位置,在雅土八方向走脚本的后面。

  6. # 预先处理:请输入每一步的帧数和总共可用的方向数

  7. $c3_每一步的帧数 = 8
  8. $c3_总共可用的方向数 = 8 #——建议不要修改这个。如果要伪8方向的,就用伪的好了。

  9. # 图片处理与功能说明:

  10. # 1、每一步的帧数:
  11. #    众所周知,RMXP的移动行走图是一个方向共有4帧,很多人都觉得这个帧数有点少。
  12. # 使用这个脚本之后,只要将 $c3_每一步的帧数 这个变量设置一个需要的帧数即可修改
  13. # 单方向移动帧数为相应输入值。修改后,需要用photoshop将所有用到的素材的横排
  14. # 调整为相应帧数,比如输入了8则要将每一行设置8个图像(即每一个行走图有8列)。

  15. # 2、可用方向调整(可用数量:4、8):
  16. #    当为4方向时没有任何变化,还是一个图4行,上左右下4个方向。
  17. #    如果想使用8方向走,将需要八方向行走的行走图在延伸扩大的画布中按照左下、右下、左上、右上继续排布图像。
  18. # 即,行走图图片从上到下的面向排列顺序为:下,左,右,上,左下,右下,左上,右上。
  19. #    至于不需要8方向走的普通的NPC(character),使用photoshop将画布向下扩大一倍即可使用。
  20. #    需要注意的是,如果需要斜方向飞鸟,请不要忘记自制素材。

  21. # 特别提示:   
  22. #     使用本脚本前请先考虑清楚是否要做这种效果。因为使用本脚本后需要用photoshop处理character行走图素材
  23. # 虽然这种处理用photoshop定义动作只需要5分钟即可全部完成,但在制作阶段会感觉不是很爽(具体的用了才知道)
  24. # 作者的建议是,如果你没有足够的制作经验,使用这个脚本得不偿失。请确保自己的能力属于“高手”级别!

  25. # 附赠功能:
  26. #     可以让NPC角色随机8方向走,方法是:NPC角色移动路线为“自定义”,然后自定义里面使用脚本,输入c8即可
  27. #     可以让NPC角色随机4斜角方向走,方法是:NPC角色移动路线为“自定义”,然后自定义里面使用脚本,输入c4即可
  28. #     可以使用真·斜4方向行走,参考脚本53行开始

  29. # 作者:carol3
  30. ###########################################################################################################################
  31. class Game_Player < Game_Character
  32. if $c3_总共可用的方向数 == 8
  33.    def update
  34.      last_moving = moving?
  35.      unless moving? or $game_system.map_interpreter.running? or
  36.             @move_route_forcing or $game_temp.message_window_showing
  37.        # 用井号后面的东西替代前面的,就可以实现斜4方向走
  38.        case Input.dir8
  39.        when 2
  40.          move_down #move_lower_left
  41.        when 4
  42.          move_left #move_upper_left
  43.        when 6
  44.          move_right #move_lower_right
  45.        when 8
  46.          move_up #move_upper_right
  47.        when 1
  48.          move_lower_left
  49.        when 3
  50.          move_lower_right
  51.        when 7
  52.          move_upper_left
  53.        when 9
  54.          move_upper_right
  55.        end
  56.      end
  57.      # 本地变量记忆坐标
  58.      last_real_x = @real_x
  59.      last_real_y = @real_y
  60.      super
  61.      # 角色向下移动、画面上的位置在中央下方的情况下
  62.      if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  63.        # 画面向下卷动
  64.        $game_map.scroll_down(@real_y - last_real_y)
  65.      end
  66.      # 角色向左移动、画面上的位置在中央左方的情况下
  67.      if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  68.        # 画面向左卷动
  69.        $game_map.scroll_left(last_real_x - @real_x)
  70.      end
  71.      # 角色向右移动、画面上的位置在中央右方的情况下
  72.      if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  73.        # 画面向右卷动
  74.        $game_map.scroll_right(@real_x - last_real_x)
  75.      end
  76.      # 角色向上移动、画面上的位置在中央上方的情况下
  77.      if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  78.        # 画面向上卷动
  79.        $game_map.scroll_up(last_real_y - @real_y)
  80.      end
  81.      # 不在移动中的情况下
  82.      unless moving?
  83.        # 上次主角移动中的情况
  84.        if last_moving
  85.          # 与同位置的事件接触就判定为事件启动
  86.          result = check_event_trigger_here([1,2])
  87.          # 没有可以启动的事件的情况下
  88.          if result == false
  89.            # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  90.            unless $DEBUG and Input.press?(Input::CTRL)
  91.              # 遇敌计数下降
  92.              if @encounter_count > 0
  93.                @encounter_count -= 1
  94.              end
  95.            end
  96.          end
  97.        end
  98.        # 按下 C 键的情况下
  99.        if Input.trigger?(Input::C)
  100.          # 判定为同位置以及正面的事件启动
  101.          check_event_trigger_here([0])
  102.          check_event_trigger_there([0,1,2])
  103.        end
  104.      end
  105.    end
  106.    #--------------------------------------------------------------------------
  107.    # ● 正面事件的启动判定
  108.    #--------------------------------------------------------------------------
  109.    def check_event_trigger_there(triggers)
  110.      result = false
  111.      # 事件执行中的情况下
  112.      if $game_system.map_interpreter.running?
  113.        return result
  114.      end
  115.      # 计算正面坐标
  116.      new_x = @x
  117.      new_y = @y
  118.      case @direction
  119.      when 1
  120.        new_x -= 1
  121.        new_y += 1
  122.      when 2
  123.        new_y += 1
  124.      when 3
  125.        new_x += 1
  126.        new_y += 1
  127.      when 4
  128.        new_x -= 1
  129.      when 6
  130.        new_x += 1
  131.      when 7
  132.        new_x -= 1
  133.        new_y -= 1
  134.      when 8
  135.        new_y -= 1
  136.      when 9
  137.        new_x += 1
  138.        new_y -= 1
  139.      end
  140.      # 全部事件的循环
  141.      for event in $game_map.events.values
  142.        # 事件坐标与目标一致的情况下
  143.        if event.x == new_x and event.y == new_y and
  144.           triggers.include?(event.trigger)
  145.          # 跳跃中以外的情况下、启动判定是正面的事件
  146.          if not event.jumping? and not event.over_trigger?
  147.            event.start
  148.            result = true
  149.          end
  150.        end
  151.      end
  152.      # 找不到符合条件的事件的情况下
  153.      if result == false
  154.        # 正面的元件是计数器的情况下
  155.        if $game_map.counter?(new_x, new_y)
  156.          # 计算 1 元件里侧的坐标
  157.          new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  158.          new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  159.          # 全事件的循环
  160.          for event in $game_map.events.values
  161.            # 事件坐标与目标一致的情况下
  162.            if event.x == new_x and event.y == new_y and
  163.               triggers.include?(event.trigger)
  164.              # 跳跃中以外的情况下、启动判定是正面的事件
  165.              if not event.jumping? and not event.over_trigger?
  166.                event.start
  167.                result = true
  168.              end
  169.            end
  170.          end
  171.        end
  172.      end
  173.      return result
  174.    end
  175. end
  176. end


  177. class Sprite_Character < RPG::Sprite
  178. def update
  179.    super
  180.    # 元件 ID、文件名、色相与现在的情况存在差异的情况下
  181.    if @tile_id != @character.tile_id or
  182.       @character_name != @character.character_name or
  183.       @character_hue != @character.character_hue
  184.      # 记忆元件 ID 与文件名、色相
  185.      @tile_id = @character.tile_id
  186.      @character_name = @character.character_name
  187.      @character_hue = @character.character_hue
  188.      # 元件 ID 为有效值的情况下
  189.      if @tile_id >= 384
  190.        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  191.          @tile_id, @character.character_hue)
  192.        self.src_rect.set(0, 0, 32, 32)
  193.        self.ox = 16
  194.        self.oy = 32
  195.      # 元件 ID 为无效值的情况下
  196.      else
  197.        self.bitmap = RPG::Cache.character(@character.character_name,
  198.          @character.character_hue)
  199.        @cw = bitmap.width / $c3_每一步的帧数
  200.        if $c3_总共可用的方向数==4
  201.          @ch = bitmap.height / 4
  202.        else
  203.          @ch = bitmap.height / 8
  204.        end
  205.        self.ox = @cw / 2
  206.        self.oy = @ch
  207.      end
  208.    end
  209.    # 设置可视状态
  210.    self.visible = (not @character.transparent)
  211.    # 图形是角色的情况下
  212.    if @tile_id == 0
  213.      # 设置传送目标的矩形
  214.      sx = @character.pattern * @cw
  215.      if $c3_总共可用的方向数==8
  216.        case @character.direction
  217.        when 2
  218.          sy = 0 * @ch
  219.        when 4
  220.          sy = 1 * @ch
  221.        when 6
  222.          sy = 2 * @ch
  223.        when 8
  224.          sy = 3 * @ch
  225.        when 1
  226.          sy = 4 * @ch
  227.        when 3
  228.          sy = 5 * @ch
  229.        when 7
  230.          sy = 6 * @ch
  231.        when 9
  232.          sy = 7 * @ch
  233.        end
  234.      else
  235.        sy = (@character.direction - 2) / 2 * @ch
  236.      end
  237.      self.src_rect.set(sx, sy, @cw, @ch)
  238.    end
  239.    # 设置脚本的坐标
  240.    self.x = @character.screen_x
  241.    self.y = @character.screen_y
  242.    self.z = @character.screen_z(@ch)
  243.    # 设置不透明度、合成方式、茂密
  244.    self.opacity = @character.opacity
  245.    self.blend_type = @character.blend_type
  246.    self.bush_depth = @character.bush_depth
  247.    # 动画
  248.    if @character.animation_id != 0
  249.      animation = $data_animations[@character.animation_id]
  250.      animation(animation, true)
  251.      @character.animation_id = 0
  252.    end
  253.    #####################################################################
  254. #  id = $game_map.map_id
  255. #   name = $data_mapinfos[id].name
  256. #   if name.include?("★") and not @character.character_name.include?("★★")
  257.     # rage = name.split(/★/)[1]
  258.     # min_rate = rage.split(/~/)[0].to_f
  259.    #  max_rate = rage.split(/~/)[1].to_f
  260.     # rate =  min_rate + (@character.y.to_f / $game_map.height.to_f * (max_rate - min_rate))
  261.    #  self.zoom_x = self.zoom_y = rate
  262. #  end
  263.    ####################################################################
  264. end
  265. end

  266. class Game_Character
  267. def c8
  268.    # 随机 0~5 的分支
  269.    case rand(10)
  270.    when 0..3  # 随机
  271.      move_random
  272.    when 4  # 前进一步
  273.      move_forward
  274.    when 5  # 暂时停止
  275.      @stop_count = 0
  276.    when 6..9  #另外4方向随机
  277.      c4
  278.    end
  279. end
  280. def c4
  281.    case rand(5)
  282.    when 0
  283.      move_upper_left
  284.      @direction = 7
  285.    when 1
  286.      move_upper_right
  287.      @direction = 9
  288.    when 2
  289.      move_lower_left
  290.      @direction = 1
  291.    when 3
  292.      move_lower_right
  293.      @direction = 3
  294.    when 4
  295.      @stop_count = 0
  296.    end
  297. end
  298.      
  299. def update
  300.    # 跳跃中、移动中、停止中的分支
  301.    if jumping?
  302.      update_jump
  303.    elsif moving?
  304.      update_move
  305.    else
  306.      update_stop
  307.    end
  308.    # 动画计数超过最大值的情况下
  309.    # ※最大值等于基本值减去移动速度 * 1 的值
  310.    if @anime_count > 16 * 4/$c3_每一步的帧数 - @move_speed # * 2
  311.      # 停止动画为 OFF 并且在停止中的情况下
  312.      if not @step_anime and @stop_count > 0
  313.        # 还原为原来的图形
  314.        @pattern = @original_pattern
  315.      # 停止动画为 ON 并且在移动中的情况下
  316.      else
  317.        # 更新图形
  318.        @pattern = (@pattern + 1) % $c3_每一步的帧数
  319.      end
  320.      # 清除动画计数
  321.      @anime_count = 0
  322.    end
  323.    # 等待中的情况下
  324.    if @wait_count > 0
  325.      # 减少等待计数
  326.      @wait_count -= 1
  327.      return
  328.    end
  329.    # 强制移动路线的场合
  330.    if @move_route_forcing
  331.      # 自定义移动
  332.      move_type_custom
  333.      return
  334.    end
  335.    # 事件执行待机中并且为锁定状态的情况下
  336.    if @starting or lock?
  337.      # 不做规则移动
  338.      return
  339.    end
  340.    # 如果停止计数超过了一定的值(由移动频度算出)
  341.    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
  342.      # 移动类型分支
  343.      case @move_type
  344.      when 1  # 随机
  345.        move_type_random
  346.      when 2  # 接近
  347.        move_type_toward_player
  348.      when 3  # 自定义
  349.        move_type_custom
  350.      end
  351.    end
  352. end
  353. end

  354. class Window_Base < Window
  355. def draw_actor_graphic(actor, x, y)
  356.    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  357.    cw = bitmap.width / $c3_每一步的帧数
  358.    ch = bitmap.height / $c3_总共可用的方向数
  359.    src_rect = Rect.new(0, 0, cw, ch)
  360.    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  361. end
  362. end

  363. class Game_Character
  364. #............................................................................
  365. #----------------------------------------------------------------------------
  366. # ● 寻路移动
  367. #----------------------------------------------------------------------------
  368. def goto(x, y)
  369.    #当操作目标为 角色 时
  370.    trg_x = x
  371.    trg_y = y
  372.    self_x = self.x
  373.    self_y = self.y
  374.    real_self_x = self.screen_x
  375.    real_self_y = self.screen_y
  376.    real_trg_x = x
  377.    real_trg_y = y
  378.    #调用寻路算法,开始计算路线
  379.    @find_path = Find_Path.new
  380.    @path = @find_path.find_short_path(self_x, self_y, trg_x, trg_y,
  381.                           real_self_x, real_self_y, real_trg_x, real_trg_y)
  382.    #开始自动移动,参照本类的 update方法
  383.    @go_path = true
  384.    #自动移动 处理位置初始化
  385.    @path_id = 0
  386. end
  387. #............................................................................
  388. #--------------------------------------------------------------------------
  389. # ● 面向主角的方向
  390. #--------------------------------------------------------------------------
  391. def turn_toward_player
  392.    # 求得与主角的坐标差
  393.    sx = @x - $game_player.x
  394.    sy = @y - $game_player.y
  395.    # 坐标相等的场合下
  396.    if sx == 0 and sy == 0
  397.      return
  398.    end
  399.    # 横侧距离长的情况下
  400.    if sx.abs > sy.abs
  401.      # 将左右方向变更为朝向主角的方向
  402.      sx > 0 ? turn_left : turn_right
  403.    # 竖侧距离长的情况下
  404.    else
  405.      # 将上下方向变更为朝向主角的方向
  406.      sy > 0 ? turn_up : turn_down
  407.    end
  408.    if sx == -1 and sy == -1
  409.      unless @direction_fix
  410.        @direction = 3
  411.      end
  412.      @stop_count = 0
  413.    elsif sx == -1 and sy == 1
  414.      unless @direction_fix
  415.        @direction = 9
  416.      end
  417.      @stop_count = 0
  418.    elsif sx == 1 and sy == -1
  419.      unless @direction_fix
  420.        @direction = 1
  421.      end
  422.      @stop_count = 0
  423.    elsif sx == 1 and sy == 1
  424.      unless @direction_fix
  425.        @direction = 7
  426.      end
  427.      @stop_count = 0
  428.    end
  429. end
  430. end
  431. #==============================================================================
  432. #==============================================================================
复制代码

评分

参与人数 1星屑 +150 收起 理由
myownroc + 150 塞糖

查看全部评分

《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-2 17:11

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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