#==============================================================================
# ★スクロール禁止 ver1.0 by USK
#------------------------------------------------------------------------------
# ・特定のスイッチがオンのときスクロールを禁止します。
#==============================================================================
=begin
・21行目のFixDisplayFlagVで設定した番号のスイッチがオンのとき
縦スクロールが禁止されます。
・22行目のFixDisplayFlagHで設定した番号のスイッチがオンのとき
横スクロールが禁止されます。
=end
##########
module SceneManager
@last_scene = nil
def self.last_scene
@last_scene
end
class << self; alias last_scene_call call; end
def self.call(scene_class)
@last_scene = @scene
last_scene_call(scene_class)
end
def self.return
@last_scene = @scene
@scene = @stack.pop
end
def self.refresh_scene
@last_scene = @scene
end
end
##########
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● 設定
#--------------------------------------------------------------------------
FixDisplayFlagV = 3 #禁止Y轴卷动的开关编号
FixDisplayFlagH = 4 #禁止X轴卷动的开关编号
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
alias :fix_display_scroll_down :scroll_down
alias :fix_display_scroll_left :scroll_left
alias :fix_display_scroll_right :scroll_right
alias :fix_display_scroll_up :scroll_up
alias :fix_display_refresh :refresh
alias :fix_display_valid? :valid?
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def fix_display?
$game_switches[FixDisplayFlagV] || $game_switches[FixDisplayFlagH]
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def need_centering?
ret = !fix_display? &&
SceneManager.scene.is_a?(Scene_Map) &&
@on_fix_display
@on_fix_display = fix_display?
ret
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def centering
div = 20
x = @display_x
dx = $game_player.x - (Graphics.width / 32 - 1) / 2.0 - x
dx /= div
y = @display_y
dy = $game_player.y - (Graphics.height / 32 - 1) / 2.0 - y
dy /= div
div.times do
set_display_pos(x, y)
x += dx
y += dy
scene = SceneManager.scene
scene.update_basic
scene.instance_variable_get(:@spriteset).update
end
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
##########
last_scene = SceneManager.last_scene
if last_scene.is_a?(Scene_Debug)
SceneManager.refresh_scene
return fix_display_refresh
end
##########
centering if need_centering?
fix_display_refresh
end
#--------------------------------------------------------------------------
# ● 下にスクロール
#--------------------------------------------------------------------------
def scroll_down(distance)
fix_display_scroll_down(distance) unless $game_switches[FixDisplayFlagV]
end
#--------------------------------------------------------------------------
# ● 左にスクロール
#--------------------------------------------------------------------------
def scroll_left(distance)
fix_display_scroll_left(distance) unless $game_switches[FixDisplayFlagH]
end
#--------------------------------------------------------------------------
# ● 右にスクロール
#--------------------------------------------------------------------------
def scroll_right(distance)
fix_display_scroll_right(distance) unless $game_switches[FixDisplayFlagH]
end
#--------------------------------------------------------------------------
# ● 上にスクロール
#--------------------------------------------------------------------------
def scroll_up(distance)
fix_display_scroll_up(distance) unless $game_switches[FixDisplayFlagV]
end
#--------------------------------------------------------------------------
# ● 有効座標判定
#--------------------------------------------------------------------------
def valid?(x, y)
ret = fix_display_valid?(x, y)
if $game_switches[FixDisplayFlagV]
ret &&= y >= @display_y && y < @display_y + (Graphics.height >> 5)
end
if $game_switches[FixDisplayFlagH]
ret &&= x >= @display_x && x < @display_x + (Graphics.width >> 5)
end
ret
end
end
##########
class Scene_Map < Scene_Base
alias :fix_display_start :start
def start
fix_display_start
$game_map.centering if $game_map.need_centering?
end
end
##########