#==============================================================================
# ■ 华丽镜头移动脚本 by 黑暗之神Kaiser.DS
#------------------------------------------------------------------------------
# 1-插入此段脚本到Main前面
# 2-功能
# a-[镜头平滑移动到事件/角色]
# 在事件里的[设置移动路线]里选择需要镜头转向的角色输入脚本kds即可
# b-[镜头跟随事件]
# 在事件里的[设置移动路线]选择好需要跟随的事件后输入脚本kds_move_start开
# 始跟随,当不想跟随时再输入kds_move_over
#==============================================================================
$平滑移动 = nil
class Scene_Map
alias kds_update update
def update
kds_update
if $平滑移动 != nil
cen_x = (320 - 16) * 4
cen_y = (240 - 16) * 4
max_x = ($game_map.width - 20) * 128
max_y = ($game_map.height - 15) * 128
display_x = [0, [$平滑移动.x * 128 - cen_x, max_x].min].max
display_y = [0, [$平滑移动.y * 128 - cen_y, max_y].min].max
if $game_map.display_x != display_x
if ($game_map.display_x - display_x).abs < 22
$game_map.display_x = display_x
else
$game_map.display_x += (display_x - $平滑移动.old_display_x)/8
end
end
if $game_map.display_y != display_y
if ($game_map.display_y - display_y).abs <= 22
$game_map.display_y = display_y
else
$game_map.display_y += (display_y - $平滑移动.old_display_y)/8
end
end
if $game_map.display_x == display_x and $game_map.display_y == display_y
$平滑移动.center($平滑移动.x, $平滑移动.y)
$平滑移动 = nil
end
return
end
end
end
class Game_Character
CENTER_X = (320 - 16) * 4
CENTER_Y = (240 - 16) * 4
attr_accessor :old_display_x
attr_accessor :old_display_y
attr_accessor :kds_move
def center(x, y)
max_x = ($game_map.width - 20) * 128
max_y = ($game_map.height - 15) * 128
$game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
$game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
end
def kds
@old_display_x = $game_map.display_x
@old_display_y = $game_map.display_y
case @id
when 0
$平滑移动 = $game_player
else
$平滑移动 = $game_map.events[@id]
end
end
def kds_move_start
@kds_move = ""
end
def kds_move_over
@kds_move = nil
end
alias kds_update update
def update
last_real_x = @real_x
last_real_y = @real_y
kds_update
if @kds_move != nil
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
end
end
end
#==============================================================================