Project1
标题:
请问怎么做计时的选项
[打印本页]
作者:
hy2000
时间:
2020-7-23 09:40
标题:
请问怎么做计时的选项
打算在剧情中加入一个审问环节,为了体现出紧迫感,想加入之前在某些游戏中看到过的计时选项。会有时间条,限时内不回答就进入额外选项,有没有比较好的思路?
作者:
shmily0725
时间:
2020-7-23 14:43
关注 同问
作者:
灯笼菜刀王
时间:
2020-7-23 15:57
本帖最后由 灯笼菜刀王 于 2020-7-23 16:00 编辑
TIME_OUT_SW = 10086 #时间到打开的开关编号
class Window_Message < Window_Selectable
def update
super
# 渐变的情况下
if @fade_in
self.contents_opacity += 24
if @input_number_window != nil
@input_number_window.contents_opacity += 24
end
if self.contents_opacity == 255
@fade_in = false
end
return
end
# 输入数值的情况下
if @input_number_window != nil
@input_number_window.update
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_variables[$game_temp.num_input_variable_id] =
@input_number_window.number
$game_map.need_refresh = true
@input_number_window.dispose
@input_number_window = nil
terminate_message
end
return
end
if @contents_showing
if $game_temp.choice_max == 0
self.pause = true
end
if $game_switches[TIME_OUT_SW]
if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
$game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
terminate_message
end
$game_switches[TIME_OUT_SW] = false
end
# 取消
if Input.trigger?(Input::B)
if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
$game_system.se_play($data_system.cancel_se)
$game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
terminate_message
end
end
# 确定
if Input.trigger?(Input::C)
if $game_temp.choice_max > 0
$game_system.se_play($data_system.decision_se)
$game_temp.choice_proc.call(self.index)
end
terminate_message
end
return
end
if @fade_out == false and $game_temp.message_text != nil
@contents_showing = true
$game_temp.message_window_showing = true
reset_window
refresh
Graphics.frame_reset
self.visible = true
self.contents_opacity = 0
if @input_number_window != nil
@input_number_window.contents_opacity = 0
end
@fade_in = true
return
end
# 没有可以显示的信息、但是窗口为可见的情况下
if self.visible
@fade_out = true
self.opacity -= 48
if self.opacity == 0
self.visible = false
@fade_out = false
$game_temp.message_window_showing = false
end
return
end
end
end
复制代码
把这个塞到MAIN前, 第一行设置好编号, 打开这个开关的时候就会强制执行选择"取消"的选项
然后在选项之前启动一个并行处理, 内容为等待XX帧, 然后打开时间到开关(记得关闭自身,避免一直处于并行处理状态) 就实现了限时回答的功能
至于计时条的UI什么的,用图片一起并行处理显示就好啦
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1