查看: 3688|回复: 11

[已经解决] 八方行走时更改角色图像

[复制链接]
梦石
0
星屑
35248
在线时间
4171 小时
注册时间
2007-12-15
回帖
9489
发表于 2016-10-17 19:04:00 | 显示全部楼层 |阅读模式
悬赏1星屑已解决
事件处理的我试了,依然不行,有时候切换不回来。
https://rpg.blue/forum.php?mod=v ... &extra=page%3D1

需要做成用开关可控的脚本,当开关打开时,以四方行走显示,当开关关闭时,当斜角移动时,切换四个方向的斜角移动图像。
因为角色至少两套斜角移动的图像。需要可以用不同开关来控制不同的斜角移动图像。
大小两套图像都在工程中。
八方行走 改图像.rar (393.1 KB, 下载次数: 136)

素材排列方式不要改,因为这种图像排列方式,我在其他事件交代时候方便。

最佳答案

查看完整内容

给。 对于你要求 “素材排列方式不要改,因为这种图像排列方式,我在其他事件交代时候方便。”:不改的话很难弄,还是用了八方向集为一张的行走图。
梦石
0
星屑
125
在线时间
171 小时
注册时间
2014-4-14
回帖
135
发表于 2016-10-17 19:04:01 | 显示全部楼层
给。 对于你要求  “素材排列方式不要改,因为这种图像排列方式,我在其他事件交代时候方便。”:不改的话很难弄,还是用了八方向集为一张的行走图。

八方行走 改图像.7z

256.18 KB, 下载次数: 99

点评

不过话说回来,如果美工够用,这个改动堪称完美。我把抖动修正以后,动作非常流畅。而且兼容待机行走跑动的并行事件。  发表于 2016-11-13 13:54
N……npc也要进行全部素材更改改成这个模式的,虽然复制中间两个方向过去就行,但是这数量……会……会死人啊救命啊T T  发表于 2016-11-13 13:53
有个问题,能不能在开启八方行走的时候,可以控制是选择用默认的图像还是改后的8方图像,否则需要动的素材太多了orz  发表于 2016-11-13 13:38
Vanyogin
回复

使用道具 举报

梦石
0
星屑
50
在线时间
104 小时
注册时间
2016-8-8
回帖
44
发表于 2016-10-17 20:48:29 | 显示全部楼层
大世界地图上是四方向斜角移动用大图,具体小场景是8方向移动用小图,是这个意思吗?

点评

用脚本控制,用开关选择是否开启,根据需要选择开启大型的还是小型的。  发表于 2016-10-17 20:58
不是,地图分两种的,xp标准地图用小号的,我自己画的场景用大型的。  发表于 2016-10-17 20:57
人性是物性的绽放,人道是天道的赓续。
回复

使用道具 举报

梦石
0
星屑
35248
在线时间
4171 小时
注册时间
2007-12-15
回帖
9489
 楼主| 发表于 2016-11-13 12:49:51 | 显示全部楼层
本帖最后由 89444640 于 2016-11-13 13:58 编辑
2357691704 发表于 2016-11-12 20:31
给。 对于你要求  “素材排列方式不要改,因为这种图像排列方式,我在其他事件交代时候方便。”:不改的话 ...


非常感谢,这样就可以节约图像容量了,我去整合一下图像继续测试。
不过事件的交代,若开着8方行走的话,比如需要角色面向左上,应该还是需要单独的面向左上的图形吧?我测试下 有问题继续请教
……突然想起个问题,若是把方向跑动…………两个斜角跑动……大型的真的好难画啊……………

npc也要全改 而且所有的事件即使补空也要改成8方向的……
这个数量……
未标题-1 拷贝.png
我还是放弃吧真改不过来了……
回复

使用道具 举报

梦石
0
星屑
125
在线时间
171 小时
注册时间
2014-4-14
回帖
135
发表于 2016-11-13 13:41:53 | 显示全部楼层
89444640 发表于 2016-11-13 12:49
非常感谢,这样就可以节约图像容量了,我去整合一下图像继续测试。
不过事件的交代,若开着8方行走的话, ...

新增加了更改面向功能:脚本:$game_player.mian_lower_left面向左下、$game_player.mian_lower_right面向左下、$game_player.mian_upper_left面向左上、$game_player.mian_upper_right面向右上。[fold=Game_Character 3八方向][pre lang="ruby"]#==============================================================================
# ■ 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 mian_lower_left #$game_player.mian_lower_left
    # 没有固定面向的场合
    unless @direction_fix
      # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  ###########################################################################
      @direction = 1
  ###########################################################################
    end
  end
  #--------------------------------------------------------------------------
  # ● 面向右下
  #--------------------------------------------------------------------------
  def mian_lower_right #$game_player.mian_lower_right
    # 没有固定面向的场合
    unless @direction_fix
      # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  ###########################################################################
      @direction = 3
  ###########################################################################
    end
  end
  #--------------------------------------------------------------------------
  # ● 面向左上
  #--------------------------------------------------------------------------
  def mian_upper_left  #$game_player.mian_upper_left
    # 没有固定面向的场合
    unless @direction_fix
      # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  ###########################################################################
      @direction = 7
  ###########################################################################
    end
  end
  #--------------------------------------------------------------------------
  # ● 面向右上
  #--------------------------------------------------------------------------
  def mian_upper_right #$game_player.mian_upper_right
    # 没有固定面向的场合
    unless @direction_fix
      # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  ###########################################################################
      @direction = 9
  ###########################################################################
    end
  end
  #--------------------------------------------------------------------------
  # ● 向左下移动
  #--------------------------------------------------------------------------
  def move_lower_left
    # 没有固定面向的场合
    unless @direction_fix
      # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  ###########################################################################
      @direction = 1
  ###########################################################################
    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 = 3
  ###########################################################################
    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 = 7
  ###########################################################################
    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 = 9
  ###########################################################################
    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

  ##################################################
  #--------------------------------------------------------------------------
  # ● 面向左下
  #--------------------------------------------------------------------------
  def turn_leftdown
    unless @direction_fix
      @direction = 1
      @stop_count = 0
    end
  end
#--------------------------------------------------------------------------
  # ● 面向右下
  #--------------------------------------------------------------------------
  def turn_rightdown
    unless @direction_fix
      @direction = 3
      @stop_count = 0
    end
  end

  #--------------------------------------------------------------------------
  # ● 面向左上
  #--------------------------------------------------------------------------
  def turn_leftup
    unless @direction_fix
      @direction = 7
      @stop_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 面向右上
  #--------------------------------------------------------------------------
  def turn_rightup
    unless @direction_fix
      @direction = 9
      @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
[/pre][/fold]



还有我不经常在线的,因为是高中党,要放双修日才上线(幸亏上学之前上来看看,不然又不能解决问题了。)

点评

非常感谢。如果真想用的话,只能改所有素材了……  发表于 2016-11-13 14:04
Vanyogin
回复

使用道具 举报

梦石
0
星屑
125
在线时间
171 小时
注册时间
2014-4-14
回帖
135
发表于 2016-11-13 14:20:54 | 显示全部楼层
本帖最后由 2357691704 于 2016-11-13 14:22 编辑

你想要的切换功能我只想到了一个苯办法,是该地图的所有的行走图都切换的。在Sprite_Character下面加一个Sprite_Character 2,在Spriteset_Map下面添加一个Spriteset_Map 2,在Scene_Map下面添加一个Scene_Map 2,就可以用脚本$scene = Scene_Map.new和$scene = Scene_Map2.new实现更换八方向或者四方向的行走图了。[fold=Sprite_Character 2]#==============================================================================
# ■ Sprite_Character
#------------------------------------------------------------------------------
#  角色显示用脚本。监视 Game_Character 类的实例、
# 自动变化脚本状态。
#==============================================================================

class Sprite_Character2 < RPG::Sprite
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_accessor :character                # 角色
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     viewport  : 查看端口
  #     character : 角色 (Game_Character)
  #--------------------------------------------------------------------------
  def initialize(viewport, character = nil)
    super(viewport)
    @character = character
    update
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    # 元件 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)
        @cw = bitmap.width / 4
        @ch = bitmap.height / 4##############################
  ###########################################################################
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    # 设置可视状态
    self.visible = (not @character.transparent)
    # 图形是角色的情况下
    if @tile_id == 0
      # 设置传送目标的矩形
      sx = @character.pattern * @cw
  ###########################################################################
      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
      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)
    if  @character.terrain_tag == 7
       self.z = $panorama2.z + self.z  
end
    # 设置不透明度、合成方式、茂密
    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
end
[/fold]
[fold=Spriteset_Map 2]#==============================================================================
# ■ Spriteset_Map
#------------------------------------------------------------------------------
#  处理地图画面活动块和元件的类。本类在
# Scene_Map 类的内部使用。
#==============================================================================

class Spriteset_Map2
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    # 生成显示端口
    @viewport1 = Viewport.new(0, 0, 640, 480)
    @viewport2 = Viewport.new(0, 0, 640, 480)
    @viewport3 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 200
    @viewport3.z = 5000
    # 生成元件地图
    @tilemap = Tilemap.new(@viewport1)
    @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
    for i in 0..6
      autotile_name = $game_map.autotile_names
      @tilemap.autotiles = RPG::Cache.autotile(autotile_name)
    end
    @tilemap.map_data = $game_map.data
    @tilemap.priorities = $game_map.priorities
    # 生成远景平面
    @Panorama = Plane.new(@viewport1)
    @panorama.z = -1000
    # 生成雾平面
    @fog = Plane.new(@viewport1)
    @fog.z = 3000
    # 生成角色活动块
    @character_sprites = []
    for i in $game_map.events.keys.sort
      sprite = Sprite_Character2.new(@viewport1, $game_map.events)##########
      @character_sprites.push(sprite)
    end
    @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
    # 生成天气
    @weather = RPG::Weather.new(@viewport1)
    # 生成图片
    @picture_sprites = []
    for i in 1..50
      @picture_sprites.push(Sprite_Picture.new(@viewport2,
        $game_screen.pictures))
    end
    # 生成计时器块
    @timer_sprite = Sprite_Timer.new
    # 刷新画面
    update
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    # 释放元件地图
    @tilemap.tileset.dispose
    for i in 0..6
      @tilemap.autotiles.dispose
    end
    @tilemap.dispose
    # 释放远景平面
    @panorama.dispose
    # 释放雾平面
    @fog.dispose
    # 释放角色活动块
    for sprite in @character_sprites
      sprite.dispose
    end
    # 释放天候
    @weather.dispose
    # 释放图片
    for sprite in @picture_sprites
      sprite.dispose
    end
    # 释放计时器块
    @timer_sprite.dispose
    # 释放显示端口
    @viewport1.dispose
    @viewport2.dispose
    @viewport3.dispose
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    # 远景与现在的情况有差异发生的情况下
    if @panorama_name != $game_map.panorama_name or
       @panorama_hue != $game_map.panorama_hue
      @panorama_name = $game_map.panorama_name
      @panorama_hue = $game_map.panorama_hue
      if @panorama.bitmap != nil
        @panorama.bitmap.dispose
        @panorama.bitmap = nil
      end
      if @panorama_name != ""
        @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
      end
      Graphics.frame_reset
    end
    # 雾与现在的情况有差异的情况下
    if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
      @fog_name = $game_map.fog_name
      @fog_hue = $game_map.fog_hue
      if @fog.bitmap != nil
        @fog.bitmap.dispose
        @fog.bitmap = nil
      end
      if @fog_name != ""
        @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
      end
      Graphics.frame_reset
    end
    # 刷新元件地图
    @tilemap.ox = $game_map.display_x / 4
    @tilemap.oy = $game_map.display_y / 4
    @tilemap.update
    # 刷新远景平面
    @panorama.ox = $game_map.display_x / 8
    @panorama.oy = $game_map.display_y / 8
    # 刷新雾平面
    @fog.zoom_x = $game_map.fog_zoom / 100.0
    @fog.zoom_y = $game_map.fog_zoom / 100.0
    @fog.opacity = $game_map.fog_opacity
    @fog.blend_type = $game_map.fog_blend_type
    @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
    @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
    @fog.tone = $game_map.fog_tone
    # 刷新角色活动块
    for sprite in @character_sprites
      sprite.update
    end
    # 刷新天候图形
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.ox = $game_map.display_x / 4
    @weather.oy = $game_map.display_y / 4
    @weather.update
    # 刷新图片
    for sprite in @picture_sprites
      sprite.update
    end
    # 刷新计时器块
    @timer_sprite.update
    # 设置画面的色调与震动位置
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    # 设置画面的闪烁色
    @viewport3.color = $game_screen.flash_color
    # 刷新显示端口
    @viewport1.update
    @viewport3.update
  end
end
[/fold]
[fold=Scene_Map 2]#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
#  处理地图画面的类。
#==============================================================================

class Scene_Map2
  #--------------------------------------------------------------------------
  # ● 主处理
  #--------------------------------------------------------------------------
  def main
    # 生成活动块
    @spriteset = Spriteset_Map2.new##############
    # 生成信息窗口
    @message_window = Window_Message.new
    # 执行过渡
    Graphics.transition
    # 主循环
    loop do
      # 刷新游戏画面
      Graphics.update
      # 刷新输入信息
      Input.update
      # 刷新画面
      update
      # 如果画面切换的话就中断循环
      if $scene != self
        break
      end
    end
    # 准备过渡
    Graphics.freeze
    # 释放活动块
    @spriteset.dispose
    # 释放信息窗口
    @message_window.dispose
    # 标题画面切换中的情况下
    if $scene.is_a?(Scene_Title)
      # 淡入淡出画面
      Graphics.transition
      Graphics.freeze
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    # 循环
    loop do
      # 按照地图、实例、主角的顺序刷新
      # (本更新顺序不会在满足事件的执行条件下成为给予角色瞬间移动
      #  的机会的重要因素)
      $game_map.update
      $game_system.map_interpreter.update
      $game_player.update
      # 系统 (计时器)、画面刷新
      $game_system.update
      $game_screen.update
      # 如果主角在场所移动中就中断循环
      unless $game_temp.player_transferring
        break
      end
      # 执行场所移动
      transfer_player
      # 处理过渡中的情况下、中断循环
      if $game_temp.transition_processing
        break
      end
    end
    # 刷新活动块
    @spriteset.update
    # 刷新信息窗口
    @message_window.update
    # 游戏结束的情况下
    if $game_temp.gameover
      # 切换的游戏结束画面
      $scene = Scene_Gameover.new
      return
    end
    # 返回标题画面的情况下
    if $game_temp.to_title
      # 切换到标题画面
      $scene = Scene_Title.new
      return
    end
    # 处理过渡中的情况下
    if $game_temp.transition_processing
      # 清除过渡处理中标志
      $game_temp.transition_processing = false
      # 执行过渡
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # 显示信息窗口中的情况下
    if $game_temp.message_window_showing
      return
    end
    # 遇敌计数为 0 且、且遇敌列表不为空的情况下
    if $game_player.encounter_count == 0 and $game_map.encounter_list != []
      # 不是在事件执行中或者禁止遇敌中
      unless $game_system.map_interpreter.running? or
             $game_system.encounter_disabled
        # 确定队伍
        n = rand($game_map.encounter_list.size)
        troop_id = $game_map.encounter_list[n]
        # 队伍有效的话
        if $data_troops[troop_id] != nil
          # 设置调用战斗标志
          $game_temp.battle_calling = true
          $game_temp.battle_troop_id = troop_id
          $game_temp.battle_can_escape = true
          $game_temp.battle_can_lose = false
          $game_temp.battle_proc = nil
        end
      end
    end
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 不是在事件执行中或菜单禁止中
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        # 设置菜单调用标志以及 SE 演奏
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
    # 调试模式为 ON 并且按下 F9 键的情况下
    if $DEBUG and Input.press?(Input::F9)
      # 设置调用调试标志
      $game_temp.debug_calling = true
    end
    # 不在主角移动中的情况下
    unless $game_player.moving?
      # 执行各种画面的调用
      if $game_temp.battle_calling
        call_battle
      elsif $game_temp.shop_calling
        call_shop
      elsif $game_temp.name_calling
        call_name
      elsif $game_temp.menu_calling
        call_menu
      elsif $game_temp.save_calling
        call_save
      elsif $game_temp.debug_calling
        call_debug
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 调用战斗
  #--------------------------------------------------------------------------
  def call_battle
    # 清除战斗调用标志
    $game_temp.battle_calling = false
    # 清除菜单调用标志
    $game_temp.menu_calling = false
    $game_temp.menu_beep = false
    # 生成遇敌计数
    $game_player.make_encounter_count
    # 记忆地图 BGM 、停止 BGM
    $game_temp.map_bgm = $game_system.playing_bgm
    $game_system.bgm_stop
    # 演奏战斗开始 SE
    $game_system.se_play($data_system.battle_start_se)
    # 演奏战斗 BGM
    $game_system.bgm_play($game_system.battle_bgm)
    # 矫正主角姿势
    $game_player.straighten
    # 切换到战斗画面
    $scene = Scene_Battle.new
  end
  #--------------------------------------------------------------------------
  # ● 调用商店
  #--------------------------------------------------------------------------
  def call_shop
    # 清除商店调用标志
    $game_temp.shop_calling = false
    # 矫正主角姿势
    $game_player.straighten
    # 切换到商店画面
    $scene = Scene_Shop.new
  end
  #--------------------------------------------------------------------------
  # ● 调用名称输入
  #--------------------------------------------------------------------------
  def call_name
    # 清除调用名称输入标志
    $game_temp.name_calling = false
    # 矫正主角姿势
    $game_player.straighten
    # 切换到名称输入画面
    $scene = Scene_Name.new
  end
  #--------------------------------------------------------------------------
  # ● 调用菜单
  #--------------------------------------------------------------------------
  def call_menu
    # 清除菜单调用标志
    $game_temp.menu_calling = false
    # 已经设置了菜单 SE 演奏标志的情况下
    if $game_temp.menu_beep
      # 演奏确定 SE
      $game_system.se_play($data_system.decision_se)
      # 清除菜单演奏 SE 标志
      $game_temp.menu_beep = false
    end
    # 矫正主角姿势
    $game_player.straighten
    # 切换到菜单画面
    $scene = Scene_Menu.new
  end
  #--------------------------------------------------------------------------
  # ● 调用存档
  #--------------------------------------------------------------------------
  def call_save
    # 矫正主角姿势
    $game_player.straighten
    # 切换到存档画面
    $scene = Scene_Save.new
  end
  #--------------------------------------------------------------------------
  # ● 调用调试
  #--------------------------------------------------------------------------
  def call_debug
    # 清除调用调试标志
    $game_temp.debug_calling = false
    # 演奏确定 SE
    $game_system.se_play($data_system.decision_se)
    # 矫正主角姿势
    $game_player.straighten
    # 切换到调试画面
    $scene = Scene_Debug.new
  end
  #--------------------------------------------------------------------------
  # ● 主角的场所移动
  #--------------------------------------------------------------------------
  def transfer_player
    # 清除主角场所移动调试标志
    $game_temp.player_transferring = false
    # 移动目标与现在的地图有差异的情况下
    if $game_map.map_id != $game_temp.player_new_map_id
      # 设置新地图
      $game_map.setup($game_temp.player_new_map_id)
    end
    # 设置主角位置
    $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
    # 设置主角朝向
    case $game_temp.player_new_direction
    when 2  # 下
      $game_player.turn_down
    when 4  # 左
      $game_player.turn_left
    when 6  # 右
      $game_player.turn_right
    when 8  # 上
      $game_player.turn_up
    end
    # 矫正主角姿势
    $game_player.straighten
    # 刷新地图 (执行并行事件)
    $game_map.update
    # 在生成活动块
    @spriteset.dispose
    @spriteset = Spriteset_Map.new
    # 处理过渡中的情况下
    if $game_temp.transition_processing
      # 清除过渡处理中标志
      $game_temp.transition_processing = false
      # 执行过渡
      Graphics.transition(20)
    end
    # 执行地图设置的 BGM、BGS 的自动切换
    $game_map.autoplay
    # 设置画面
    Graphics.frame_reset
    # 刷新输入信息
    Input.update
  end
end
[/fold]

(我去上学了,再见啦~~)
Vanyogin
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部