Project1
标题:
关于“待机动画”和“行走帧数改变”的问题
[打印本页]
作者:
根五
时间:
2011-10-1 01:28
标题:
关于“待机动画”和“行走帧数改变”的问题
本帖最后由 亿万星辰 于 2011-10-1 14:35 编辑
这2个脚本有一定的冲突,一个要求后缀为“_W” 一个要求后缀为“_(行走图帧数)”
我把行走图后缀改成“_6" 待机动画改成“_6_W"解决了这个问题。
可是我用的是自制的片头,就是用自制菜单的方法做的,现在问题来了,
我的意思是开始没有初期同伴,然后动画和情节完了之后再加入主角!可是这样点F12后会显示
找不到“Gr....../Ch....../_W 这个我怎么都没法弄好,只好来求助脚本上的改变了。
行走图设成空白的方法不行。如果这样的话刚开始没问题,可是一到情节完了人物一行走就又变成空白图片了,不管是用 更改角色图片 还是 离开/加入 都是这样!
这个是 待机动画 脚本
#==============================================================================
# ■ Game_Character (分割定义 1)
#------------------------------------------------------------------------------
# 处理角色的类。本类作为 Game_Player 类与 Game_Event
# 类的超级类使用。
#==============================================================================
class Game_Character
attr_accessor :time
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
alias old_ini initialize
def initialize
old_ini
@time = 0
end
end
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
# 处理主角的类。事件启动的判定、以及地图的滚动等功能。
# 本类的实例请参考 $game_player。
#==============================================================================
class Game_Player < Game_Character
TIME_LIMIT = 5 # 抓耳挠腮前的等待时间 (好象也不是帧…不知道是什么单位了)
#--------------------------------------------------------------------------
# ● 画面更新
#--------------------------------------------------------------------------
def update
# 本地变量记录移动信息
last_moving = moving?
if @time == TIME_LIMIT
@character_name = @character_name + "_W"
@scratch = true
@step_anime = true
@time = TIME_LIMIT + 1
elsif @time < TIME_LIMIT
@scratch = false
@step_anime = false
end
if @scratch == false
@old_pic = @character_name
end
# 移动中、事件执行中、强制移动路线中、
# 信息窗口一个也不显示的时候
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# 如果方向键被按下、主角就朝那个方向移动
case Input.dir4
when 2
move_down
@time = 0
@scratch = false
@character_name = @old_pic
when 4
move_left
@time = 0
@scratch = false
@character_name = @old_pic
when 6
move_right
@time = 0
@scratch = false
@character_name = @old_pic
when 8
move_up
@time = 0
@scratch = false
@character_name = @old_pic
end
end
# 本地变量记忆坐标
last_real_x = @real_x
last_real_y = @real_y
super
# 角色向下移动、画面上的位置在中央下方的情况下
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# 画面向下卷动
$game_map.scroll_down(@real_y - last_real_y)
end
# 角色向左移动、画面上的位置在中央左方的情况下
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# 画面向左卷动
$game_map.scroll_left(last_real_x - @real_x)
end
# 角色向右移动、画面上的位置在中央右方的情况下
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# 画面向右卷动
$game_map.scroll_right(@real_x - last_real_x)
end
# 角色向上移动、画面上的位置在中央上方的情况下
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# 画面向上卷动
$game_map.scroll_up(last_real_y - @real_y)
end
# 不在移动中的情况下
unless moving?
@time += 1 if @time < TIME_LIMIT
# 上次主角移动中的情况
if last_moving
# 与同位置的事件接触就判定为事件启动
result = check_event_trigger_here([1,2])
# 没有可以启动的事件的情况下
if result == false
# 调试模式为 ON 并且按下 CTRL 键的情况下除外
unless $DEBUG and Input.press?(Input::CTRL)
# 遇敌计数下降
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 判定为同位置以及正面的事件启动
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
end
复制代码
这个是 行走图帧数改变 脚本
#========================================
# 本脚本来自www.66rpg.com
#========================================
class Game_Character
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 跳跃中、移动中、停止中的分支
if jumping?
update_jump
elsif moving?
update_move
else
update_stop
end
# 动画计数超过最大值的情况下
# ※最大值等于基本值减去移动速度 * 1 的值
if @anime_count > 18 - @move_speed * 2
# 停止动画为 OFF 并且在停止中的情况下
if not @step_anime and @stop_count > 0
# 还原为原来的图形
@pattern = @original_pattern
# 停止动画为 ON 并且在移动中的情况下
else
# 更新图形
fps = @character_name.split(/_/)[1] != nil ? @character_name.split(/_/)[1].to_i : 4
@pattern = (@pattern + 1) % fps
end
# 清除动画计数
@anime_count = 0
end
# 等待中的情况下
if @wait_count > 0
# 减少等待计数
@wait_count -= 1
return
end
# 强制移动路线的场合
if @move_route_forcing
# 自定义移动
move_type_custom
return
end
# 事件执行待机中并且为锁定状态的情况下
if @starting or lock?
# 不做规则移动
return
end
# 如果停止计数超过了一定的值(由移动频度算出)
if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
# 移动类型分支
case @move_type
when 1 # 随机
move_type_random
when 2 # 接近
move_type_toward_player
when 3 # 自定义
move_type_custom
end
end
end
end
#===============================================
# ■ Sprite_Character
#-------------------------------------------------
# 角色显示用脚本。监视 Game_Character 类的实例、
# 自动变化脚本状态。
#===============================================
class Sprite_Character < RPG::Sprite
#---------------------------------------
# ● 更新画面
#-----------------------------------------
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)
fps = @character.character_name.split(/_/)[1] != nil ? @character.character_name.split(/_/)[1].to_i : 4
@cw = bitmap.width / fps
@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
sy = (@character.direction - 2) / 2 * @ch
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
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1