赞 | 0 |
VIP | 0 |
好人卡 | 4 |
积分 | 0 |
经验 | 639 |
最后登录 | 2014-6-12 |
在线时间 | 107 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 49
- 在线时间
- 107 小时
- 注册时间
- 2012-5-1
- 帖子
- 45
|
使用说明
数据库->图块中的备注理填写 [fp_type 地形标记ID 脚印类型]
普通脚印使用 normal
例如: [fp_type 1 normal] 表示 1 号地形标记使用普通脚印
使用时必须在 Graphics/Characters 中放置一个脚印的行走图(文件名 $footprint)
图片格式如一般行走图,不过没有动画时只需要正中间一栏即可(参考范例)
使用其他类型时,需要再 Graphics/Characters 中放置一个脚印的行走图
文件名为 $footprint + 下划线 + 类型名称
如 $footprint_blood 那么在备注中就能使用 [fp_type 1 blood] 调用
如果需要使用斜方向的脚印,那就再放一个斜方向的行走图
格式由上至下为 右上、右下、左上、左下
文件名为 普通文件名 + _dia
如 $footprint_dia 就是对应 $footprint 的斜方向行走图
$footprint_blood_dia 就是对应 $footprint_blood 的斜方向行走图
斜方向脚印会在转弯时自动使用
没有对应文件时会自动忽略
数据库->图块中的备注理填写 [fp_sound 地形标记ID 音效文件名]
就可以调用 Audio/SE 中的音效文件
数据库->图块中的备注理填写 [fp_fade 秒数]
可以设定某图块中脚印消失的速度
没有填写时默认为 5
设定为 0 时则不会消失(不过会渐渐拖慢速度)- 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
- #--------------------------------------------------------------------------
- # ● 清除移动资讯
- #--------------------------------------------------------------------------
- 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
复制代码 |
|