| 
 
| 赞 | 0 |  
| VIP | 9 |  
| 好人卡 | 0 |  
| 积分 | 1 |  
| 经验 | 18278 |  
| 最后登录 | 2018-5-1 |  
| 在线时间 | 210 小时 |  
 Lv1.梦旅人 
	梦石0 星屑85 在线时间210 小时注册时间2013-7-26帖子346 | 
3楼
 
 
 楼主|
发表于 2015-1-16 21:53:44
|
只看该作者 
| 如何向左上 右上 左下 右下 移动 待机动画的名称为  行走图名称+"_W1"
 @RyanBern
 @布罗利
 复制代码#==============================================================================
# ■ Game_Character (分割定义 1)
#------------------------------------------------------------------------------
#  处理角色的类。本类作为 Game_Player 类与 Game_Event
# 类的超级类使用。
#==============================================================================
class Game_Character
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :id                       # ID
  attr_reader   :x                        # 地图 X 坐标 (理论坐标)
  attr_reader   :y                        # 地图 Y 坐标 (理论坐标)
  attr_reader   :real_x                   # 地图 X 坐标 (实际坐标 * 128)
  attr_reader   :real_y                   # 地图 Y 坐标 (实际坐标 * 128)
  attr_reader   :tile_id                  # 元件 ID  (0 为无效)
  attr_reader   :character_name           # 角色 文件名
  attr_reader   :character_hue            # 角色 色相
  attr_reader   :opacity                  # 不透明度
  attr_reader   :blend_type               # 合成方式
  attr_reader   :direction                # 朝向
  attr_reader   :pattern                  # 图案
  attr_reader   :move_route_forcing       # 移动路线强制标志
  attr_reader   :through                  # 穿透
  attr_accessor :animation_id             # 动画 ID
  attr_accessor :transparent              # 透明状态
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    @id = 0
    @x = 0
    @y = 0
    @real_x = 0
    @real_y = 0
    @tile_id = 0
    @character_name = ""
    @character_hue = 0
    @opacity = 255
    @blend_type = 0
    @direction = 2
    @pattern = 0
    @move_route_forcing = false
    @through = false
    @animation_id = 0
    @transparent = false
    @original_direction = 2
    @original_pattern = 0
    @move_type = 0
    @move_speed = 3
    @move_frequency = 6
    @move_route = nil
    @move_route_index = 0
    @original_move_route = nil
    @original_move_route_index = 0
    @walk_anime = true
    @step_anime = false
    @direction_fix = false
    @always_on_top = false
    @anime_count = 0
    @stop_count = 0
    @jump_count = 0
    @jump_peak = 0
    @wait_count = 0
    @locked = false
    @prelock_direction = 0
  end
  #--------------------------------------------------------------------------
  # ● 移动中判定
  #--------------------------------------------------------------------------
  def moving?
    # 如果在移动中理论坐标与实际坐标不同
    return (@real_x != @x * 128 or @real_y != @y * 128)
  end
  #--------------------------------------------------------------------------
  # ● 跳跃中判定
  #--------------------------------------------------------------------------
  def jumping?
    # 如果跳跃中跳跃点数比 0 大
    return @jump_count > 0
  end
  #--------------------------------------------------------------------------
  # ● 矫正姿势
  #--------------------------------------------------------------------------
  def straighten
    # 移动时动画以及停止动画为 ON 的情况下
    if @walk_anime or @step_anime
      # 设置图形为 0
      @pattern = 0
    end
    # 清除动画计数
    @anime_count = 0
    # 清除被锁定的向前朝向
    @prelock_direction = 0
  end
  #--------------------------------------------------------------------------
  # ● 强制移动路线
  #     move_route : 新的移动路线
  #--------------------------------------------------------------------------
  def force_move_route(move_route)
    # 保存原来的移动路线
    if @original_move_route == nil
      @original_move_route = @move_route
      @original_move_route_index = @move_route_index
    end
    # 更改移动路线
    @move_route = move_route
    @move_route_index = 0
    # 设置强制移动路线标志
    @move_route_forcing = true
    # 清除被锁定的向前朝向
    @prelock_direction = 0
    # 清除等待计数
    @wait_count = 0
    # 自定义移动
    move_type_custom
  end
  #--------------------------------------------------------------------------
  # ● 可以通行判定
  #     x : X 坐标
  #     y : Y 坐标
  #     d : 方向 (0,2,4,6,8)  ※ 0 = 全方向不能通行的情况判定 (跳跃用)
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    # 求得新的坐标
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    # 坐标在地图以外的情况
    unless $game_map.valid?(new_x, new_y)
      # 不能通行
      return false
    end
    # 穿透是 ON 的情况下
    if @through
      # 可以通行
      return true
    end
    # 移动者的元件无法来到指定方向的情况下
    unless $game_map.passable?(x, y, d, self)
      # 通行不可
      return false
    end
    # 从指定方向不能进入到移动处的元件的情况下
    unless $game_map.passable?(new_x, new_y, 10 - d)
      # 不能通行
      return false
    end
    # 循环全部事件
    for event in $game_map.events.values
      # 事件坐标于移动目标坐标一致的情况下
      if event.x == new_x and event.y == new_y
        # 穿透为 ON
        unless event.through
          # 自己就是事件的情况下
          if self != $game_player
            # 不能通行
            return false
          end
          # 自己是主角、对方的图形是角色的情况下
          if event.character_name != ""
            # 不能通行
            return false
          end
        end
      end
    end
    # 主角的坐标与移动目标坐标一致的情况下
    if $game_player.x == new_x and $game_player.y == new_y
      # 穿透为 ON
      unless $game_player.through
        # 自己的图形是角色的情况下
        if @character_name != ""
          # 不能通行
          return false
        end
      end
    end
    # 可以通行
    return true
  end
  #--------------------------------------------------------------------------
  # ● 锁定
  #--------------------------------------------------------------------------
  def lock
    # 如果已经被锁定的情况下
    if @locked
      # 过程结束
      return
    end
    # 保存锁定前的朝向
    @prelock_direction = @direction
    # 保存主角的朝向
    turn_toward_player
    # 设置锁定中标志
    @locked = true
  end
  #--------------------------------------------------------------------------
  # ● 锁定中判定
  #--------------------------------------------------------------------------
  def lock?
    return @locked
  end
  #--------------------------------------------------------------------------
  # ● 解除锁定
  #--------------------------------------------------------------------------
  def unlock
    # 没有锁定的情况下
    unless @locked
      # 过程结束
      return
    end
    # 清除锁定中标志
    @locked = false
    # 没有固定朝向的情况下
    unless @direction_fix
      # 如果保存了锁定前的方向
      if @prelock_direction != 0
        # 还原为锁定前的方向
        @direction = @prelock_direction
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 移动到指定位置
  #     x : X 坐标
  #     y : Y 坐标
  #--------------------------------------------------------------------------
  def moveto(x, y)
    @x = x % $game_map.width
    @y = y % $game_map.height
    @real_x = @x * 128
    @real_y = @y * 128
    @prelock_direction = 0
  end
  #--------------------------------------------------------------------------
  # ● 获取画面 X 坐标
  #--------------------------------------------------------------------------
  def screen_x
    # 通过实际坐标和地图的显示位置来求得画面坐标
    return (@real_x - $game_map.display_x + 3) / 4 + 16
  end
  #--------------------------------------------------------------------------
  # ● 获取画面 Y 坐标
  #--------------------------------------------------------------------------
  def screen_y
    # 通过实际坐标和地图的显示位置来求得画面坐标
    y = (@real_y - $game_map.display_y + 3) / 4 + 32
    # 取跳跃计数小的 Y 坐标
    if @jump_count >= @jump_peak
      n = @jump_count - @jump_peak
    else
      n = @jump_peak - @jump_count
    end
    return y - (@jump_peak * @jump_peak - n * n) / 2
  end
  #--------------------------------------------------------------------------
  # ● 获取画面 Z 坐标
  #     height : 角色的高度
  #--------------------------------------------------------------------------
  def screen_z(height = 0)
    # 在最前显示的标志为 ON 的情况下
    if @always_on_top
      # 无条件设置为 999
      return 999
    end
    # 通过实际坐标和地图的显示位置来求得画面坐标
    z = (@real_y - $game_map.display_y + 3) / 4 + 32
    # 元件的情况下
    if @tile_id > 0
      # 元件的优先不足 * 32 
      return z + $game_map.priorities[@tile_id] * 32
    # 角色的场合
    else
      # 如果高度超过 32 就判定为满足 31
      return z + ((height > 32) ? 31 : 0)
    end
  end
  #--------------------------------------------------------------------------
  # ● 取得茂密
  #--------------------------------------------------------------------------
  def bush_depth
    # 是元件、并且在最前显示为 ON 的情况下
    if @tile_id > 0 or @always_on_top
      return 0
    end
    # 以跳跃中以外要是繁茂处属性的元件为 12,除此之外为 0
    if @jump_count == 0 and $game_map.bush?(@x, @y)
      return 12
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 取得地形标记
  #--------------------------------------------------------------------------
  def terrain_tag
    return $game_map.terrain_tag(@x, @y)
  end
end
复制代码#==============================================================================
# ■ Game_Character (分割定义 3)
#------------------------------------------------------------------------------
#  处理角色的类。本类作为 Game_Player 类与 Game_Event
# 类的超级类使用。
#==============================================================================
class Game_Character
  #--------------------------------------------------------------------------
  # ● 向下移动
  #     turn_enabled : 本场地位置更改许可标志
  #--------------------------------------------------------------------------
  def move_down(turn_enabled = true)
    # 面向下
    if turn_enabled
      turn_down
    end
    # 可以通行的场合
    if passable?(@x, @y, 2)
      # 面向下
      turn_down
      # 更新坐标
      @y += 1
      # 增加步数
      increase_steps
    # 不能通行的情况下
    else
      # 接触事件的启动判定
      check_event_trigger_touch(@x, @y+1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 向左移动
  #     turn_enabled : 本场地位置更改许可标志
  #--------------------------------------------------------------------------
  def move_left(turn_enabled = true)
    # 面向左
    if turn_enabled
      turn_left
    end
    # 可以通行的情况下
    if passable?(@x, @y, 4)
      # 面向左
      turn_left
      # 更新坐标
      @x -= 1
      # 增加步数
      increase_steps
    # 不能通行的情况下
    else
      # 接触事件的启动判定
      check_event_trigger_touch(@x-1, @y)
    end
  end
  #--------------------------------------------------------------------------
  # ● 向右移动
  #     turn_enabled : 本场地位置更改许可标志
  #--------------------------------------------------------------------------
  def move_right(turn_enabled = true)
    # 面向右
    if turn_enabled
      turn_right
    end
    # 可以通行的场合
    if passable?(@x, @y, 6)
      # 面向右
      turn_right
      # 更新坐标
      @x += 1
      # 增加部数
      increase_steps
    # 不能通行的情况下
    else
      # 接触事件的启动判定
      check_event_trigger_touch(@x+1, @y)
    end
  end
  #--------------------------------------------------------------------------
  # ● 向上移动
  #     turn_enabled : 本场地位置更改许可标志
  #--------------------------------------------------------------------------
  def move_up(turn_enabled = true)
    # 面向上
    if turn_enabled
      turn_up
    end
    # 可以通行的情况下
    if passable?(@x, @y, 8)
      # 面向上
      turn_up
      # 更新坐标
      @y -= 1
      # 歩数増加
      increase_steps
    # 不能通行的情况下
    else
      # 接触事件的启动判定
      check_event_trigger_touch(@x, @y-1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 向左下移动
  #--------------------------------------------------------------------------
  def move_lower_left
    # 没有固定面向的场合
    unless @direction_fix
      # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
      @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
    end
    # 下→左、左→下 的通道可以通行的情况下
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
      # 更新坐标
      @x -= 1
      @y += 1
      # 增加步数
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # ● 向右下移动
  #--------------------------------------------------------------------------
  def move_lower_right
    # 没有固定面向的场合
    unless @direction_fix
      # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
      @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
    end
    # 下→右、右→下 的通道可以通行的情况下
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
      # 更新坐标
      @x += 1
      @y += 1
      # 增加步数
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # ● 向左上移动
  #--------------------------------------------------------------------------
  def move_upper_left
    # 没有固定面向的场合
    unless @direction_fix
      # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
      @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
    end
    # 上→左、左→上 的通道可以通行的情况下
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
      # 更新坐标
      @x -= 1
      @y -= 1
      # 增加步数
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # ● 向右上移动
  #--------------------------------------------------------------------------
  def move_upper_right
    # 没有固定面向的场合
    unless @direction_fix
      # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
      @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
    end
    # 上→右、右→上 的通道可以通行的情况下
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
      # 更新坐标
      @x += 1
      @y -= 1
      # 增加步数
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # ● 随机移动
  #--------------------------------------------------------------------------
  def move_random
    case rand(4)
    when 0  # 向下移动
      move_down(false)
    when 1  # 向左移动
      move_left(false)
    when 2  # 向右移动
      move_right(false)
    when 3  # 向上移动
      move_up(false)
    end
  end
  #--------------------------------------------------------------------------
  # ● 接近主角
  #--------------------------------------------------------------------------
  def move_toward_player
    # 求得与主角的坐标差
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    # 坐标相等情况下
    if sx == 0 and sy == 0
      return
    end
    # 求得差的绝对值
    abs_sx = sx.abs
    abs_sy = sy.abs
    # 横距离与纵距离相等的情况下
    if abs_sx == abs_sy
      # 随机将边数增加 1
      rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
    end
    # 横侧距离长的情况下
    if abs_sx > abs_sy
      # 左右方向优先。向主角移动
      sx > 0 ? move_left : move_right
      if not moving? and sy != 0
        sy > 0 ? move_up : move_down
      end
    # 竖侧距离长的情况下
    else
      # 上下方向优先。向主角移动
      sy > 0 ? move_up : move_down
      if not moving? and sx != 0
        sx > 0 ? move_left : move_right
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 远离主角
  #--------------------------------------------------------------------------
  def move_away_from_player
    # 求得与主角的坐标差
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    # 坐标相等情况下
    if sx == 0 and sy == 0
      return
    end
    # 求得差的绝对值
    abs_sx = sx.abs
    abs_sy = sy.abs
    # 横距离与纵距离相等的情况下
    if abs_sx == abs_sy
      # 随机将边数增加 1
      rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
    end
    # 横侧距离长的情况下
    if abs_sx > abs_sy
      # 左右方向优先。远离主角移动
      sx > 0 ? move_right : move_left
      if not moving? and sy != 0
        sy > 0 ? move_down : move_up
      end
    # 竖侧距离长的情况下
    else
      # 上下方向优先。远离主角移动
      sy > 0 ? move_down : move_up
      if not moving? and sx != 0
        sx > 0 ? move_right : move_left
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 前进一步
  #--------------------------------------------------------------------------
  def move_forward
    case @direction
    when 2
      move_down(false)
    when 4
      move_left(false)
    when 6
      move_right(false)
    when 8
      move_up(false)
    end
  end
  #--------------------------------------------------------------------------
  # ● 后退一步
  #--------------------------------------------------------------------------
  def move_backward
    # 记忆朝向固定信息
    last_direction_fix = @direction_fix
    # 强制固定朝向
    @direction_fix = true
    # 朝向分支
    case @direction
    when 2  # 下
      move_up(false)
    when 4  # 左
      move_right(false)
    when 6  # 右
      move_left(false)
    when 8  # 上
      move_down(false)
    end
    # 还原朝向固定信息
    @direction_fix = last_direction_fix
  end
  #--------------------------------------------------------------------------
  # ● 跳跃
  #     x_plus : X 坐标增加值
  #     y_plus : Y 坐标增加值
  #--------------------------------------------------------------------------
  def jump(x_plus, y_plus)
    # 增加值不是 (0,0) 的情况下
    if x_plus != 0 or y_plus != 0
      # 横侧距离长的情况下
      if x_plus.abs > y_plus.abs
        # 变更左右方向
        x_plus < 0 ? turn_left : turn_right
      # 竖侧距离长的情况下
      else
        # 变更上下方向
        y_plus < 0 ? turn_up : turn_down
      end
    end
    # 计算新的坐标
    new_x = @x + x_plus
    new_y = @y + y_plus
    # 增加值为 (0,0) 的情况下、跳跃目标可以通行的场合
    if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
      # 矫正姿势
      straighten
      # 更新坐标
      @x = new_x
      @y = new_y
      # 距计算距离
      distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
      # 设置跳跃记数
      @jump_peak = 10 + distance - @move_speed
      @jump_count = @jump_peak * 2
      # 清除停止记数信息
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 面向向下
  #--------------------------------------------------------------------------
  def turn_down
    unless @direction_fix
      @direction = 2
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 面向向左
  #--------------------------------------------------------------------------
  def turn_left
    unless @direction_fix
      @direction = 4
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 面向向右
  #--------------------------------------------------------------------------
  def turn_right
    unless @direction_fix
      @direction = 6
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 面向向上
  #--------------------------------------------------------------------------
  def turn_up
    unless @direction_fix
      @direction = 8
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 向右旋转 90 度
  #--------------------------------------------------------------------------
  def turn_right_90
    case @direction
    when 2
      turn_left
    when 4
      turn_up
    when 6
      turn_down
    when 8
      turn_right
    end
  end
  #--------------------------------------------------------------------------
  # ● 向左旋转 90 度
  #--------------------------------------------------------------------------
  def turn_left_90
    case @direction
    when 2
      turn_right
    when 4
      turn_down
    when 6
      turn_up
    when 8
      turn_left
    end
  end
  #--------------------------------------------------------------------------
  # ● 旋转 180 度
  #--------------------------------------------------------------------------
  def turn_180
    case @direction
    when 2
      turn_up
    when 4
      turn_right
    when 6
      turn_left
    when 8
      turn_down
    end
  end
  #--------------------------------------------------------------------------
  # ● 从右向左旋转 90 度
  #--------------------------------------------------------------------------
  def turn_right_or_left_90
    if rand(2) == 0
      turn_right_90
    else
      turn_left_90
    end
  end
  #--------------------------------------------------------------------------
  # ● 随机变换方向
  #--------------------------------------------------------------------------
  def turn_random
    case rand(4)
    when 0
      turn_up
    when 1
      turn_right
    when 2
      turn_left
    when 3
      turn_down
    end
  end
  #--------------------------------------------------------------------------
  # ● 接近主角的方向
  #--------------------------------------------------------------------------
  def turn_toward_player
    # 求得与主角的坐标差
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    # 坐标相等的场合下
    if sx == 0 and sy == 0
      return
    end
    # 横侧距离长的情况下
    if sx.abs > sy.abs
      # 将左右方向变更为朝向主角的方向
      sx > 0 ? turn_left : turn_right
    # 竖侧距离长的情况下
    else
      # 将上下方向变更为朝向主角的方向
      sy > 0 ? turn_up : turn_down
    end
  end
  #--------------------------------------------------------------------------
  # ● 背向主角的方向
  #--------------------------------------------------------------------------
  def turn_away_from_player
    # 求得与主角的坐标差
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    # 坐标相等的场合下
    if sx == 0 and sy == 0
      return
    end
    # 横侧距离长的情况下
    if sx.abs > sy.abs
      # 将左右方向变更为背离主角的方向
      sx > 0 ? turn_right : turn_left
    # 竖侧距离长的情况下
    else
      # 将上下方向变更为背离主角的方向
      sy > 0 ? turn_down : turn_up
    end
  end
end
复制代码#==============================================================================
# ■ Sprite_Character
#------------------------------------------------------------------------------
#  角色显示用脚本。监视 Game_Character 类的实例、
# 自动变化脚本状态。
#==============================================================================
class Sprite_Character < RPG::Sprite
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_accessor :character                # 角色
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     viewport  : 查看端口
  #     character : 角色 (Game_Character)
  #--------------------------------------------------------------------------
  def initialize(viewport, character = nil)
    super(viewport)
    [url=home.php?mod=space&uid=2631396]@character[/url] = character
    # 事件显示名字脚本加强★★★★★★★★★★★★★★★★★★★★★★★★★
    name = character.name
    @namesprite = Sprite.new(viewport)
    @namesprite.bitmap = Bitmap.new(160, 48)
    @namesprite.bitmap.font.name = "宋体"
    @namesprite.bitmap.font.size = 16
    @namesprite.bitmap.font.color.set(255, 250, 0, 255)      # 黄色
    @evname = name
    @evname_split = name.split(/,/)[0]
    if name.split(/,/)[1] != nil
      case name.split(/,/)[1]
      when "0"
        @namesprite.bitmap.font.color.set(60, 255, 80, 255)  # 绿色
      when "1"
        @namesprite.bitmap.font.color.set(190, 130, 0, 255)  # 橙色
      when "2"
        @namesprite.bitmap.font.color.set(0, 120, 210, 255)  # 蓝色
      when "3"
        @namesprite.bitmap.font.color.set(255, 0, 50, 255)   # 红色
      end
    end
    if @evname_split != "" and @evname_split != nil and not $game_temp.in_battle
      @namesprite.bitmap.draw_text(0, 0, 160, 36, @evname_split, 1)
    end
    # 事件显示名字脚本加强★★★★★★★★★★★★★★★★★★★★★★★★★
    update
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    # 事件显示名字脚本加强★★★★★★★★★★★★★★★★★★★★★★★★★
    if @evname != @character.name
      @namesprite.bitmap.clear
    end
    @namesprite.x = self.x - 80    # 显示坐标
    @namesprite.y = self.y - self.oy - 24 + 130  # 显示坐标
    # 元件 ID、文件名、色相与现在的情况存在差异的情况下
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      # 记忆元件 ID 与文件名、色相
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      # 元件 ID 为有效值的情况下
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      # 元件 ID 为无效值的情况下
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        # 素材处理★★★★★★★★★★★★★★★★★★★★★★★★★★★
        # 需要使用特殊的素材文件名为识别处理的情况时!列如:
        # 当素材文件名为“场所移动”时,对该素材处理方法
        if @character_name == "场所移动"  
          @cw = bitmap.width / 19
          @ch = bitmap.height
        # 除此以外,其他素材和角色行走图等素材的处理  
        else    
          @cw = bitmap.width / 8
          @ch = bitmap.height / 8
        end
        # ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★   
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    # 设置可视状态
    self.visible = (not @character.transparent)
    # 图形是角色的情况下
    if @tile_id == 0
      # 设置传送目标的矩形
      sx = @character.pattern * @cw
      # 八向素材处理★★★★★★★★★★★★★★★★★★★★★★★★★★★
      # 需要使用特殊的素材文件名为识别处理的情况时!列如:
        if @character_name == "场所移动"  
          sy = 0 * @ch
        else
          case @character.direction
          when 2
            sy = 0 * @ch   #  下
          when 4
            sy = 1 * @ch   #  左
          when 6
            sy = 2 * @ch   #  右
          when 8
            sy = 3 * @ch   #  上
          when 1
            sy = 4 * @ch   #  左下
          when 3
            sy = 5 * @ch   #  右下
          when 7
            sy = 6 * @ch   #  左上
          when 9
            sy = 7 * @ch   #  右上
          end
        end
      # ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
      self.src_rect.set(sx, sy, @cw, @ch)
    end
    # 设置脚本的坐标
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    # 设置不透明度、合成方式、茂密
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    # 动画
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
  end
  def dispose
    super
    unless @namesprite.disposed?
      @namesprite.bitmap.dispose
      @namesprite.dispose
    end
  end
end
 | 
 |