Project1

标题: 这个怎么插到脚本里 [打印本页]

作者: yang1zhi    时间: 2015-12-5 12:38
标题: 这个怎么插到脚本里
等待N秒
$game_variables[19] += 1
if $game_variables[19]  ==  60
$game_variables[20] += 1
end
if  $game_variables[20] ==  24
$game_variables[21] += 1
end




如您所见,这是时钟。
我之前是把PlayTime改成时钟。也解决了归零问题。
新的问题是不能加时间。
假设我去旅店睡觉经过多少时间,加进时钟里。

所以我想用变量来表示,操作起来应该更方便。

您可能觉得这可以用公共事件来等待N真执行。

但是公共事件并非一直都是运行的,有些情况下是不动的,比如战斗。


我把$game_variables[19] = 1放到
RUBY 代码复制
  1. def refresh
  2.     self.contents.clear
  3.     self.contents.font.color = system_color
  4.     self.contents.draw_text(4, 0, 120, 32, "游戏时间")
  5.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  6.     min = @total_sec / 60 % 24
  7.     sec = @total_sec % 60
  8.     $game_variables[19] = 1
  9.     text = sprintf("%02d时%02d分", min, sec)
  10.     self.contents.font.color = normal_color
  11.     self.contents.draw_text(4, 32, 120, 32, text, 2)
  12.   end



这样并没有效果。只有在游戏中执行def refresh时才会有效果。
作者: 枫の叶    时间: 2015-12-5 13:37
游戏中一秒:Graphics.frame_count % Graphics.frame_rate == 0
当一秒时,你可以 $game_variables[19] += 1 , 总秒数就是 $game_variables[19]
当前秒数:$game_variables[19]  % 60
分钟:$game_variables[19] / 60 % 60
小时:$game_variables[19] / 60 / 60 % 24
天   :$game_variables[19] / 60 / 60 / 24
可以把脚本里 @total_sec = Graphics.frame_count / Graphics.frame_rate
改成 @total_sec = $game_variables[19] ,再加一个天数显示就行了。
作者: cinderelmini    时间: 2015-12-5 15:28
本帖最后由 cinderelmini 于 2015-12-5 15:32 编辑

要加时间的话,其实很简单啊。。
还是弄Graphics.frame_count这个东西……
时间中【脚本】输入
  1. Graphics.frame_count += 60*n
复制代码
60是一秒,n是秒数,自己算一下然后加上去就好啦。

例:去旅馆休息一晚上(12小时):
【脚本】》 Graphics.frame_count += ((60*60)*60)*12
然后赋值变量为游戏时间……




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1