こんばんは。
メッセージの表示を行う際に、「背景を暗くする」を使って映画のような演出をしているのですが
選択肢のウィンドウや数値入力のウィンドウを表示した際、「通常ウィンドウ」で表示されてしまいます。
(通常ウィンドウの画像ファイルはメニュー画面で使っています)
ですので、選択肢や数値入力ウィンドウの背景も「背景を暗くする」と同じようにしたいのです。
(なにせ、枠線を消したい)
スクリプトで実装するとしたらどのような方法があるでしょうか?
【スクリプト】数値入力や選択肢ウィンドウの背景を変えたい。
Re: 【スクリプト】数値入力や選択肢ウィンドウの背景を変えたい。
私の所で配布してるスクリプトを元に作ってみました
『〇〇Synchronize』をtrueにすると、
メッセージウィンドウと同時に開く際に背景が同期します
また、メッセージウィンドウが閉じてるか、『〇〇Synchronize』がfalseの場合は、
『〇〇Variable』で指定した変数の値に対応します
コード: 全て選択
module TOMO
module ChoiceNumberBack
# 選択肢ウィンドウをメッセージウィンドウと同期するか?
ChoiceSynchronize = false
# 選択肢ウィンドウの背景用変数ID
#
# ChoiceSynchronizeをfalseにした場合用
# (0:通常、1:暗い、2:透明)
ChoiceVariable = 1
# 数値入力ウィンドウをメッセージウィンドウと同期するか?
NumberSynchronize = false
# 数値入力ウィンドウの背景用変数ID
#
# NumberSynchronizeをfalseにした場合用
# (0:通常、1:暗い、2:透明)
NumberVariable = 2
end
end
class Window_ChoiceList < Window_Command
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias tomo_message_synchronize_initialize initialize
def initialize(message_window)
tomo_message_synchronize_initialize(message_window)
create_back_bitmap
create_back_sprite
end
#--------------------------------------------------------------------------
# ● 入力処理の開始
#--------------------------------------------------------------------------
alias tomo_message_synchronize_start start
def start
if $game_message.visible && TOMO::ChoiceNumberBack::ChoiceSynchronize
self.opacity = $game_message.background == 0 ? 255 : 0
else
id = TOMO::ChoiceNumberBack::ChoiceVariable
self.opacity = $game_variables[id] == 0 ? 255 : 0
end
tomo_message_synchronize_start
dispose_back_bitmap
create_back_bitmap
@back_sprite1.bitmap = @back_bitmap1
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias tomo_message_synchronize_update update
def update
tomo_message_synchronize_update
update_back_sprite
end
#--------------------------------------------------------------------------
# ● 終了処理
#--------------------------------------------------------------------------
def dispose
super
dispose_back_bitmap
dispose_back_sprite
end
#--------------------------------------------------------------------------
# ● 背景ビットマップの作成
#--------------------------------------------------------------------------
def create_back_bitmap
@back_bitmap1 = Bitmap.new(width, height)
rect1 = Rect.new(0, 0, width, 12)
rect2 = Rect.new(0, 12, width, height - 24)
rect3 = Rect.new(0, height - 12, width, 12)
@back_bitmap1.gradient_fill_rect(rect1, back_color2, back_color1, true)
@back_bitmap1.fill_rect(rect2, back_color1)
@back_bitmap1.gradient_fill_rect(rect3, back_color1, back_color2, true)
end
#--------------------------------------------------------------------------
# ● 背景色 1 の取得
#--------------------------------------------------------------------------
def back_color1
Color.new(0, 0, 0, 160)
end
#--------------------------------------------------------------------------
# ● 背景色 2 の取得
#--------------------------------------------------------------------------
def back_color2
Color.new(0, 0, 0, 0)
end
#--------------------------------------------------------------------------
# ● 背景スプライトの作成
#--------------------------------------------------------------------------
def create_back_sprite
@back_sprite1 = Sprite.new
@back_sprite1.bitmap = @back_bitmap1
@back_sprite1.visible = false
@back_sprite1.z = z - 1
end
#--------------------------------------------------------------------------
# ● 背景ビットマップの解放
#--------------------------------------------------------------------------
def dispose_back_bitmap
@back_bitmap1.dispose
end
#--------------------------------------------------------------------------
# ● 背景スプライトの解放
#--------------------------------------------------------------------------
def dispose_back_sprite
@back_sprite1.dispose
end
#--------------------------------------------------------------------------
# ● 背景スプライトの更新
#--------------------------------------------------------------------------
def update_back_sprite
if $game_message.visible && TOMO::ChoiceNumberBack::ChoiceSynchronize
@back_sprite1.visible = ($game_message.background == 1)
else
id = TOMO::ChoiceNumberBack::ChoiceVariable
@back_sprite1.visible = ($game_variables[id] == 1)
end
@back_sprite1.x = x
@back_sprite1.y = y
@back_sprite1.opacity = openness
@back_sprite1.update
end
end
class Window_NumberInput < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias tomo_message_synchronize_initialize initialize
def initialize(message_window)
tomo_message_synchronize_initialize(message_window)
create_back_bitmap
create_back_sprite
end
#--------------------------------------------------------------------------
# ● 入力処理の開始
#--------------------------------------------------------------------------
alias tomo_message_synchronize_start start
def start
if $game_message.visible && TOMO::ChoiceNumberBack::NumberSynchronize
self.opacity = $game_message.background == 0 ? 255 : 0
else
id = TOMO::ChoiceNumberBack::NumberVariable
self.opacity = $game_variables[id] == 0 ? 255 : 0
end
tomo_message_synchronize_start
dispose_back_bitmap
create_back_bitmap
@back_sprite2.bitmap = @back_bitmap2
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias tomo_message_synchronize_update update
def update
tomo_message_synchronize_update
update_back_sprite
end
#--------------------------------------------------------------------------
# ● 終了処理
#--------------------------------------------------------------------------
def dispose
super
dispose_back_bitmap
dispose_back_sprite
end
#--------------------------------------------------------------------------
# ● 背景ビットマップの作成
#--------------------------------------------------------------------------
def create_back_bitmap
bw = width == 0 ? 20 + padding * 2 : width
@back_bitmap2 = Bitmap.new(bw, fitting_height(1))
rect1 = Rect.new(0, 0, width, 12)
rect2 = Rect.new(0, 12, width, height - 24)
rect3 = Rect.new(0, height - 12, width, 12)
@back_bitmap2.gradient_fill_rect(rect1, back_color2, back_color1, true)
@back_bitmap2.fill_rect(rect2, back_color1)
@back_bitmap2.gradient_fill_rect(rect3, back_color1, back_color2, true)
end
#--------------------------------------------------------------------------
# ● 背景色 1 の取得
#--------------------------------------------------------------------------
def back_color1
Color.new(0, 0, 0, 160)
end
#--------------------------------------------------------------------------
# ● 背景色 2 の取得
#--------------------------------------------------------------------------
def back_color2
Color.new(0, 0, 0, 0)
end
#--------------------------------------------------------------------------
# ● 背景スプライトの作成
#--------------------------------------------------------------------------
def create_back_sprite
@back_sprite2 = Sprite.new
@back_sprite2.bitmap = @back_bitmap2
@back_sprite2.visible = false
@back_sprite2.z = z - 1
end
#--------------------------------------------------------------------------
# ● 背景ビットマップの解放
#--------------------------------------------------------------------------
def dispose_back_bitmap
@back_bitmap2.dispose
end
#--------------------------------------------------------------------------
# ● 背景スプライトの解放
#--------------------------------------------------------------------------
def dispose_back_sprite
@back_sprite2.dispose
end
#--------------------------------------------------------------------------
# ● 背景スプライトの更新
#--------------------------------------------------------------------------
def update_back_sprite
if $game_message.visible && TOMO::ChoiceNumberBack::NumberSynchronize
@back_sprite2.visible = ($game_message.background == 1)
else
id = TOMO::ChoiceNumberBack::NumberVariable
@back_sprite2.visible = ($game_variables[id] == 1)
end
@back_sprite2.x = x
@back_sprite2.y = y
@back_sprite2.opacity = openness
@back_sprite2.update
end
end
メッセージウィンドウと同時に開く際に背景が同期します
また、メッセージウィンドウが閉じてるか、『〇〇Synchronize』がfalseの場合は、
『〇〇Variable』で指定した変数の値に対応します
現在サポート終了中