赞 | 4 |
VIP | 71 |
好人卡 | 22 |
积分 | 7 |
经验 | 32145 |
最后登录 | 2013-8-9 |
在线时间 | 184 小时 |
Lv2.观梦者 天仙
- 梦石
- 0
- 星屑
- 675
- 在线时间
- 184 小时
- 注册时间
- 2008-4-15
- 帖子
- 5023

|
晕~~
说起来容易,作出来难 (竟然给我频频跳出『不要修改系统时间』)
只好用另一种方法了,把系统时间带入变数, 然後变数以与系统时间同等速度增加
说起来乾脆直接用变数好了~~{/pz}
直接替换之前我给出的真实时间脚本
- #================================================================================#
- #****Window_Time #
- #--------------------------------------------------------------------------------#
- # 显示时间的窗口类 #
- #================================================================================#
- class Window_Time < Window_Base
- #----------------------#
- #*初始化对象 #
- #----------------------#
- def initialize
-
- $time_date_running = 7 #真实时间视窗显示/不显示
- $real_time_format = 8 #真实时间的模式开关编号
- $hour = 2 #小时的变量ID
- $time_range = 3 #纪录时段的变量ID
- $check_system_time = false
- #设定窗口
- super(0, 425, 320, 55)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.opacity = 255
-
- $game_switches[$real_time_format] = true #真实时间12小时制
- $game_switches[$time_date_running] = true
-
- #刷新窗口
- refresh
- end # end def initialize
- #----------------------#
- #*刷新 #
- #----------------------#
- def refresh
- self.contents.clear
- self.contents.font.size = 18
-
- if $check_system_time == false
- @time = Time.now
- @time_sec = @time.sec
- @time_min = @time.min
- @time_hour = @time.hour
- @time_day = @time.day
- @time_month = @time.month
- @time_year = @time.year
- $check_system_time = true
- end
-
- #让检查时间的变数与系统时间同步计算
- @total_sec = Graphics.frame_count
- if @total_sec % 2400 == 0
- @time_min += 1
- end
- if @time_min >= 61
- @time_hour += 1
- @time_min = 1
- end
- if @time_hour >= 24
- @time_day += 1
- @time_hour = 1
- end
- @time_year % 4 == 0 ? feb_max = 29 : feb_max = 28
- month_max = [nil,31, feb_max, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][@time_month]
- if @time_day >= month_max + 1
- @time_month += 1
- @time_day = 1
- end
- if @time_month >= 13
- @time_year += 1
- @time_month = 1
- end
-
- self.contents.clear
- self.contents.font.size = 22
-
- if $game_switches[$real_time_format] == true
- if @time_hour >= 12
- @time_hour -= 12
- text = "PM"
- else
- text = "AM"
- end # end if
- else
- text = ""
- end # end if
-
- self.contents.draw_text(224, -5, 128, 32, text)
- self.contents.draw_text(4, -5, 128, 32, @time_year.to_s + "年")
- self.contents.draw_text(78, -5, 128, 32, @time_month.to_s + "月")
- self.contents.draw_text(116, -5, 128, 32, @time_day.to_s + "日")
- self.contents.draw_text(160, -5, 128, 32, @time_hour.to_s + " :" + @time_min.to_s)
-
- weektxt = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"][@time.wday]
- self.contents.draw_text(480, -5, 128, 32, weektxt)
-
-
- #时段控制
- $game_variables[$hour] = @time.hour #注意是"."
- case $game_variables[$hour]
- when 8
- $game_variables[$time_range] = 1 #上午
- when 12
- $game_variables[$time_range] = 2 #中午
- when 13
- $game_variables[$time_range] = 3 #下午
- when 17
- $game_variables[$time_range] = 4 #傍晚
- when 19
- $game_variables[$time_range] = 5 #晚上
- end
- end # end def refresh
- #----------------------#
- #*刷新画面 #
- #----------------------#
- def update
- super
- refresh
- end # end def update
- end# end class Window_time
- #================================================================================#
- #****Scene_Map #
- #--------------------------------------------------------------------------------#
- # 处理地图画面的类别。 #
- #================================================================================#
- class Scene_Map
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- alias timedate_main main
- def main
- # 产生活动区块
- @spriteset = Spriteset_Map.new
- # 产生讯息视窗
- @message_window = Window_Message.new
- # 产生时间视窗
- @time_window = Window_Time.new
- if $game_switches[$time_date_running] == false
- @time_window.visible = false
- end # end if
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 更新游戏画面
- Graphics.update
- # 更新输入讯息
- Input.update
- # 更新画面
- update
- # 如果画面切换的话就中断循环
- if $scene != self
- break
- end # end if
- end # end loop
- # 准备过渡
- Graphics.freeze
- # 释放活动区块
- @spriteset.dispose
- # 释放讯息视窗
- @message_window.dispose
- # 释放时间视窗
- @time_window.dispose
- # 标题画面切换中的情况下
- if $scene.is_a?(Scene_Title)
- # 淡入淡出画面
- Graphics.transition
- Graphics.freeze
- end # end if
- end # end def main
-
- alias timedate_update update
- def update
-
- #如果时间日期功能开关为OFF则不显示时间视窗
- if $game_switches[$time_date_running] == false
- @time_window.visible = false
- else
- @time_window.visible = true
- end # end if
- @time_window.refresh
- timedate_update
- end # end def update
- end #end class Scene_Map
复制代码
由於带入系统时间只在 initialize发生
所以当玩家更改系统时间时不会被更新
作息的开关也就不会被影响
不过还是有个破绽,就是如果玩家关闭游戏重新进入的话
时间就会被update
不过这也是没办法的事~~ 系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~ |
|