查看: 1766|回复: 6

[已经解决] 请问怎么用事件做出脚步声和脚印

[复制链接]
梦石
0
星屑
50
在线时间
13 小时
注册时间
2013-7-9
回帖
13
发表于 2013-7-13 20:24:26 | 显示全部楼层 |阅读模式

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

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

×
QAQ或者脚本也可以 我用朋友给的脚本弄了半天也不对
梦石
0
星屑
50
在线时间
13 小时
注册时间
2013-7-9
回帖
13
 楼主| 发表于 2013-7-13 20:26:44 | 显示全部楼层
class RPG::Tileset
  #--------------------------------------------------------------------------
  # ● 获取脚印类型
  #--------------------------------------------------------------------------
  def get_footprint_type(tag_id)
    return false unless tag_id.is_a?(Integer)
    self.note.split(/[\r\n]+/).each { |line|
      if line =~ /\[fp_type #{tag_id} (\S+)\]/
        return $1.to_sym
      end
    }
    return :none
  end
  #--------------------------------------------------------------------------
  # ● 获取脚印音效
  #--------------------------------------------------------------------------
  def get_footprint_sound(tag_id)
    return false unless tag_id.is_a?(Integer)
    self.note.split(/[\r\n]+/).each { |line|
      if line =~ /\[fp_sound #{tag_id} (\S+)\]/
        return $1
      end
    }
    return ""
  end
  #--------------------------------------------------------------------------
  # ● 获取脚印淡出速度
  #--------------------------------------------------------------------------
  def get_footprint_fade
    self.note.split(/[\r\n]+/).each { |line|
      if line =~ /\[fp_fade (\d+)\]/
        return $1.to_i
      end
    }
    return 5
  end
end
class Game_Footprint < Game_CharacterBase
  attr_reader :type
  attr_accessor :pattern
  attr_accessor :character_name
  attr_accessor :direction
  attr_accessor :direction_fix
#--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(t)
    super()
    return unless $game_player
    @direction = $game_player.direction
    self.type = t
    @move_speed = 4
    @move_frequency = 6
    @priority_type = 0
    @through = true
    @transparent = true
    moveto($game_player.x, $game_player.y)
  end
  #--------------------------------------------------------------------------
  # ● 设置类型
  #--------------------------------------------------------------------------
  def type=(t)
    @type = t
    @character_name = "$footprint"
    if @type != :normal
      @character_name += "_" + @type.to_s
    end
    case @type
    when :ripple
      @step_anime = true
      @stop_count = 8
    end
  end
  #--------------------------------------------------------------------------
  # ● 脚印更新
  #--------------------------------------------------------------------------
  def update
    super
    return if pos?($game_player.x, $game_player.y)
    fadespeed = $game_map.tileset.get_footprint_fade
    return if fadespeed == 0
    if Graphics.frame_count % fadespeed == 0
      @opacity -= 10
    end
  end
end

class Game_Footprints
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize
    @data = []
  end
  #--------------------------------------------------------------------------
  # ● 加入脚印
  #--------------------------------------------------------------------------
  def push_fp(t=:normal)
    footp = Game_Footprint.new(t)
    footp.moveto($game_player.x, $game_player.y)
    footp.set_direction($game_player.direction)
    @data.push(footp)
  end
  #--------------------------------------------------------------------------
  # ● 设置类型
  #--------------------------------------------------------------------------
  def type=(t)
    @data.each{ |ft|
      ft.type = t
    }
  end
  attr_reader :data
end
class Game_Player < Game_Character
#--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize
    @data = []
  end
  #--------------------------------------------------------------------------
  # ● 加入脚印
  #--------------------------------------------------------------------------
  def push_fp(t=:normal)
    footp = Game_Footprint.new(t)
    footp.moveto($game_player.x, $game_player.y)
    footp.set_direction($game_player.direction)
    @data.push(footp)
  end
  #--------------------------------------------------------------------------
  # ● 设置类型
  #--------------------------------------------------------------------------
  def type=(t)
    @data.each{ |ft|
      ft.type = t
    }
  end
  attr_reader :data
end
class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # ● 清除移动资讯
  #--------------------------------------------------------------------------
  alias footprint_clear_transfer_info clear_transfer_info
  def clear_transfer_info
    footprint_clear_transfer_info
    @footprint = Game_Footprints.new
  end

attr_reader :data
end
class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # ● 清除移动资讯
  #--------------------------------------------------------------------------
  alias footprint_clear_transfer_info clear_transfer_info
  def clear_transfer_info
    footprint_clear_transfer_info
    @footprint = Game_Footprints.new
  end
  #--------------------------------------------------------------------------
  # ● 返回脚印列表
  #--------------------------------------------------------------------------
  def footprints
    return @footprint.data
  end
  #alias footprint_moveto moveto
  #def moveto(x, y)
  #  footprint_moveto(x, y)
    #push_footprint
  #end
  #--------------------------------------------------------------------------
  # ● 直线移动
  #--------------------------------------------------------------------------
  alias footprint_move_straight move_straight
  def move_straight(d, turn_ok = true)
    previous_direction = @direction
    footprint_move_straight(d, turn_ok)
    if @move_succeed
      push_footprint(previous_direction)
    end
  end
#--------------------------------------------------------------------------
  # ● 新增脚印
  #--------------------------------------------------------------------------
  def push_footprint(prev_dir=2)
    return unless SceneManager.scene_is?(Scene_Map)
    if @footprint.data.size > 0
      adjust_diagonal_footprint(prev_dir, $game_player.direction)
      @footprint.data[-1].transparent = false
    end
    type = check_terrain?
    return unless type
    @footprint.push_fp(type)
    SceneManager.scene.add_footprint_sprite(@footprint.data[-1])
  end
  def adjust_diagonal_footprint(last_dir, curr_dir)
    return if last_dir == curr_dir
    footprint = @footprint.data[-1]
    name = footprint.character_name + "_dia"
    return unless FileTest.exist?("Graphics/Characters/#{name}.png")
    footprint.character_name = name
    case last_dir+curr_dir
    when 6
      footprint.direction = 8
    when 8
      footprint.direction = 4
    when 12
      footprint.direction = 6
    when 14
      footprint.direction = 2
    end
  end
  #--------------------------------------------------------------------------
  # ● 检查地形
  #--------------------------------------------------------------------------
  def check_terrain?
    terrain = $game_map.terrain_tag($game_player.x, $game_player.y)
    type  = $game_map.tileset.get_footprint_type(terrain)
    sound = $game_map.tileset.get_footprint_sound(terrain)
    RPG::SE.new(sound).play if sound != ""
    if type == :none
      return false
    else
      return type
    end
  end
end
class Spriteset_Map
  #--------------------------------------------------------------------------
  # ● 增加脚印精灵
  #--------------------------------------------------------------------------
  def add_footprint(footprint)
    @character_sprites.push(Sprite_Character.new(@viewport1, footprint))
  end
  #--------------------------------------------------------------------------
  # ● 更新角色精灵
  #--------------------------------------------------------------------------
  alias footprint_update_characters update_characters
  def update_characters
    footprint_update_characters # 调用原有方法
    update_footsteps # 更新脚印
  end
  #--------------------------------------------------------------------------
  # ● 更新脚印精灵
  #--------------------------------------------------------------------------
  def update_footsteps
    @character_sprites.each {|sprite|
      if sprite.character.is_a?(Game_Footprint)
        sprite.character.update
        if sprite.opacity <= 0 # 不透明度为0时
          @character_sprites.delete(sprite) # 移除精灵
          sprite.dispose # 释放脚印精灵
        end
      end
    }
  end
end
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # ● 加入脚印精灵
  #--------------------------------------------------------------------------
  def add_footprint_sprite(footprint)
    @spriteset.add_footprint(footprint)
  end
  #--------------------------------------------------------------------------
  # ● 创建地图精灵组
  #--------------------------------------------------------------------------
  alias footprint_create_spriteset create_spriteset
  def create_spriteset
    footprint_create_spriteset
    $game_player.push_footprint
  end
end


窝朋友给的脚本第38行出错用不了QAQ
回复

使用道具 举报

送快递的水表员

梦石
10
星屑
5259
在线时间
3304 小时
注册时间
2012-6-27
回帖
7028

开拓者贵宾

发表于 2013-7-13 21:58:16 | 显示全部楼层
麻烦提供下脚步声的素材,也许我能帮忙做一个。
回复

使用道具 举报

梦石
0
星屑
60
在线时间
93 小时
注册时间
2013-6-14
回帖
75
发表于 2013-7-15 21:19:43 | 显示全部楼层
地图布满所有事件,都是与主角接触后触发,然后再SE里面添加脚步声,执行事件时播放SE。至于脚印,就设置个角色图形呗,也在同一事件里,并允许穿透。主要是看你有没有这么多素材。方法先告诉你了。(其实我也是个新手呵呵)

点评

这个不行,太浪费资源了,满地图有效事件会非常非常卡  发表于 2013-7-27 23:44

评分

参与人数 1星屑 +1 收起 理由
怪蜀黍 + 1 这个不行,太浪费资源了

查看全部评分

回复

使用道具 举报

嗜谎者

梦石
4
星屑
19316
在线时间
4012 小时
注册时间
2010-9-12
回帖
9248

超评测评委极短28评委极短27评委MZ评测员极短26评委极短25评委极短24评委极短23评委极短22评委极短21评委开拓者

发表于 2013-7-27 23:46:47 | 显示全部楼层
地图内放置一个并行事件,事件内容如下:
判定变量X=玩家脚步数,
符合的情况下不执行
不符合的情况下执行,
执行内容为
播放SE“脚步声”
变量X+1
结束

不过这个简单事件虽然简单,有不少问题,不知道应用性怎么样(我没试过)

评分

参与人数 1星屑 +95 收起 理由
怪蜀黍 + 95 目测可以

查看全部评分

回复

使用道具 举报

伴侣:北岛谜烟

发表于 2013-7-28 19:09:11 | 显示全部楼层
纯粹路过

脚步声.rar (246.62 KB, 下载次数: 88)

点评

是自己做的还是转载?如果是自己做的请PM我撤销评分,我发好人卡。  发表于 2013-8-11 09:06

评分

参与人数 1星屑 +100 收起 理由
怪蜀黍 + 100 认可答案

查看全部评分

本人收不到提醒(点评|回复|@人),总之有事情到空间留言一起普通普通
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部