谁能看看这个脚本错在哪里?
rpgmaker吧
全部回复
仅看楼主
level 3
2013年07月31日 00点07分 1
level 3
度娘啊……
各位大神,这个脚本是我改的,属于Game_Character 3类,不知错在哪里,靠近主角总出错。
#--------------------------------------------------------------------------
# ● 接近主角
#--------------------------------------------------------------------------
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
# 左右方向优先。向主角移动
if sx > 0
move_left
end
if sx < 0
move_right
end
if not moving? and sx = 0
if sy > 0
move_up
end
if sy < 0
move_down
end
end
return
# 竖侧距离长的情况下
else
# 上下方向优先。向主角移动
if sy > 0
move_up
end
if sy < 0
move_down
end
if not moving? and sy = 0
if sx > 0
move_left
end
if sx < 0
move_right
end
end
return
end
end
2013年07月31日 00点07分 6
level 2
网络工人
←←←←←←
←←←←←←
←←←←←←
←←←←←←
←←←←←←
百分百可靠,欢迎!
掭苔诎桂
fdye
2013年07月31日 01点07分 7
[冷]广告还是赚经验
2013年07月31日 02点07分
1