Graphics.transition
loop do
Graphics.update
Input.update
update
if self != $scene
break
end
end
Graphics.freeze
@bank_window.dispose
@gold_window.dispose
@command_window.dispose
@number_window.dispose
@command_window_1.dispose
end
def update
@command_window.update
@number_window.update
@command_window_1.update
if @command_window.active
update_command
return
end
if @number_window.active
update_number
return
end
if @command_window_1.active
update_command_1
return
end
end
def update_command
if Input.trigger?(Input::B)
$scene = Scene_Map.new
end
if Input.trigger?(Input::C)
case @command_window.index
when 0
@command_window.active = false
@number_window.active = true
@command_window_1.active=false
when 1
@command_window.active = false
@number_window.active = true
@command_window_1.active=false
when 2
$scene=Scene_Map.new
end
end
end
def update_number
if Input.trigger?(Input::B)
@command_window.active = true
@number_window.active = false
@command_window_1.active=false
end
if Input.trigger?(Input::C)
@command_window.active = false
@number_window.active = false
@command_window_1.active=true
end
end
def update_command_1
if Input.trigger?(Input::B)
@command_window.active = false
@number_window.active = true
@command_window_1.active=false
end
if Input.trigger?(Input::C)
case @command_window.index
when 0
@command_window_1=Window_Command.new(192,
["确定存入#{@number_window.number}","取消"])
@command_window_1.x=192
@command_window_1.y=64
case @command_window_1.index
when 0
$game_party.lose_gold(@number_window.number)
@gold_window.refresh
$game_party.gain_gold_1(@number_window.number)
@bank_window.refresh
when 1
$scene=self
end
when 1
@command_window_1=Window_Command.new(192,
["确定取出#{@number_window.number}","取消"])
case @command_window_1.index
when 0
$game_party.lose_gold_1(@number_window.number)
@bank_window.refresh
$game_party.gain_gold(@number_window.number)
@gold_window.refresh
when 1
$scene=self
end
when 2
$scene=Scene_Map.new
end
@command_window.active = true
@number_window.active = false
@command_window_1.active=false
end
end
end
class Window_Bank < Window_Base
def initialize
super(160,0,480,64)
self.contents=Bitmap.new(width-32,height-32)
refresh
end
def refresh
self.contents.clear
cw=self.contents.text_size($data_system.words.gold).width
self.contents.draw_text(0,0,480-32-cw,32,$game_party.gold_1.to_s)
self.contents.draw_text(480-32-cw,0,cw,32,$data_system.words.gold,2)
end
end
class Window_Number<Window_Base
def initialize
super(0,64+32*4,192,64)
self.contents = Bitmap.new(width - 32, height - 32)
@number = 0
refresh
end
def refresh
self.contents.clear
self.contents.draw_text(0, 0, 24, 32, @number.to_s, 2)
self.cursor_rect.set(0, 0, 32, 32)
end
def update
super
if self.active
# 光标右 (+1)
if Input.repeat?(Input::RIGHT)
@number += 1
refresh
end
# 光标左 (-1)
if Input.repeat?(Input::LEFT) and @number > 0
@number -= 1
refresh
end
# 光标上 (+10)
if Input.repeat?(Input::UP)
@number = @number + 10
refresh
end
# 光标下 (-10)
if Input.repeat?(Input::DOWN) and @number > 0
@number = @number - 10
refresh
end
end
end
def number
return @number
end
end
class Game_Party
attr_reader :gold_1
alias bank_initialize initialize
def initialize
bank_initialize
@gold_1=0
end
def gain_gold_1(n)
@gold_1 = @gold_1 + n
end
def lose_gold_1(n)
@gold_1 = @gold_1 - n
end
end作者: 魔法丶小肉包 时间: 2024-7-20 00:45
稍微提点小建议(
首先你这个Scene_Bank中的update里的那些if xxx.active这些条件中呢,其实没什么必要return,毕竟我看你同时就只有一个窗口在active,那么其实另外两个条件本来就进不去的
然后就是case这里,既然你0和1是在做同一件事,那么直接when 0,1就可以了,不需要多写一遍的作者: 百里_飞柳 时间: 2024-7-20 11:42
第一,用脚本框,这样真的很难看()