| 赞 | 14 |
| VIP | |
| 好人卡 | |
| 积分 | 6 |
| 经验 | |
| 最后登录 | 2026-8-9 |
| 在线时间 | 797 小时 |
- 梦石
- 0
- 星屑
- 606
- 在线时间
- 797 小时
- 注册时间
- 2014-7-1
- 回帖
- 501

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
我现在用的是 芯☆淡茹水的多组多功能计时器
不过现在有一个问题:这个计时器是在游戏地图上直接显示的 如果有几十个计时器同时在计时就很麻烦
有没有办法将计时器的时间显示在其他窗口 比如一个新的界面窗口 用 $scene = Scene_XX.new在游戏中调用界面来查看计算的时间!?
- #==============================================================================
- # ★ 多组多功能计时器 ★ -> by 芯☆淡茹水
- #==============================================================================
- # ● 使用方法:1,复制脚本,插入到 main 前。
- #
- # 2,启动计时:
- #
- # 事件 -> 脚本 :$game_system.start_time(tit, min, switch, add)
- #
- # 括号里的参数:tit -> 标题 。比如:双倍经验时间;副本时间,等
- # 代入的参数为 字符串 。由于计时窗口宽度
- # 有限,标题最好不要超过 5 个汉字。
- #
- # min -> 计时时间X分钟。(注意是分钟,可以是小数)
- #
- # switch -> 计时完成后打开的开关ID。
- #
- # add -> 正计时标志。需要正计时写 true ,不需要
- # 时可不写。
- #
- # 3,中途取消计时:
- #
- # 事件 -> 脚本:$game_system.end_time(switch_id)
- #
- # 括号里的参数:switch_id -> 对应的计时器打开的开关ID。
- #==============================================================================
- # ● 说明:
- # 该计时器理论上可同时无限个计时。
- #
- # 计时窗口只在地图场景显示,战斗场景不显示计时窗口,但仍然会计时,
- # 其他场景不计时。
- #
- # 计时完成后自动打开启动计时时设置的开关,需要实现什么功能可通过事件,
- # 开关,公共事件,等,来协调完成。这个就自己开脑洞。
- # 可参照范例工程的示范(事件,公共事件)。
- #
- #==============================================================================
- # ● 设置:
- module X☆R
- #--------------------------------------------------------------------------
- # 计时窗口 X 坐标。
- TM_WINDOW_X = 400
-
- #--------------------------------------------------------------------------
- # 计时窗口 Y 坐标。
- TM_WINDOW_Y = 0
-
- #--------------------------------------------------------------------------
- # 计时窗口标题字体颜色。
- TM_TIT_COLOR = Color.new(0,255,255)
-
- #--------------------------------------------------------------------------
- # 计时窗时间字体颜色(30 秒以上)。
- TM_TIME_COLOR1 = Color.new(0,85,0)
-
- #--------------------------------------------------------------------------
- # 计时窗时间字体颜色(10 - 30 秒)。
- TM_TIME_COLOR2 = Color.new(255,120,0)
-
- #--------------------------------------------------------------------------
- # 计时窗时间字体颜色(0 - 10 秒)。
- TM_TIME_COLOR3 = Color.new(200,0,0)
-
- #--------------------------------------------------------------------------
- # 最后 10 秒是否声音提示?
- TM_SOUND_TIP = true
-
- #--------------------------------------------------------------------------
- # 声音提示的 SE 文件名。
- TM_SOUND = "032-Switch01"
- end
- #==============================================================================
- class Time_Meter
- attr_reader :switch_id, :title, :add_count
- attr_accessor :sec, :max_sec
- #--------------------------------------------------------------------------
- def initialize(title, min, switch_id, add)
- @title = title
- @max_sec = @sec = Integer(min * 60)
- @sec = 0 if add
- @switch_id = switch_id
- @add_count = add ? 1 : -1
- end
- #--------------------------------------------------------------------------
- def sec_judge
- return @add_count > 0 ? @sec < @max_sec : @sec > 0
- end
- #--------------------------------------------------------------------------
- def update
- @sec += @add_count if sec_judge and Graphics.frame_count % Graphics.frame_rate == 0
- unless sec_judge
- $game_switches[@switch_id] = true
- $game_map.need_refresh = true
- end
- if @data_sec != @sec and @add_count < 0
- @data_sec = @sec
- if @sec < 10 and X☆R::TM_SOUND_TIP and $scene.is_a?(Scene_Map)
- Audio.se_play("Audio/SE/#{X☆R::TM_SOUND}", 80, 100)
- end
- end
- end
- end
- #==============================================================================
- class Window_Tm < Sprite
- #--------------------------------------------------------------------------
- def initialize(x, y, time)
- super()
- self.x = x
- self.y = y
- self.z = 9999
- @time = time
- bitmap = RPG::Cache.character($game_player.character_name, $game_player.character_hue)
- @b_width = bitmap.width / 8
- @b_height = bitmap.height / 4
- end
- #--------------------------------------------------------------------------
- def dispose
- self.bitmap.dispose if self.bitmap
- super
- end
- #--------------------------------------------------------------------------
- def refresh
- self.bitmap.dispose if self.bitmap
- self.bitmap = Bitmap.new("Graphics/Pictures/Time_meter_back")
- self.bitmap.font.size = 18
- self.bitmap.font.bold = true
- cx = self.bitmap.text_size(@time.title).width
- self.bitmap.font.color = X☆R::TM_TIT_COLOR
- self.bitmap.draw_text(35, 0, cx, 30, @time.title)
- if @time.add_count > 0
- color = X☆R::TM_TIME_COLOR1
- else
- color = @time.sec >= 30 ? X☆R::TM_TIME_COLOR1 :
- (@time.sec >= 10 ? X☆R::TM_TIME_COLOR2 : X☆R::TM_TIME_COLOR3)
- end
- hour = @time.sec / 3600
- min = @time.sec / 60 % 60
- sec = @time.sec % 60
- text = sprintf("%02d:%02d:%02d", hour, min, sec)
- self.bitmap.font.color = color
- self.bitmap.draw_text(130, 0, 90, 30, text, 2)
- end
- #--------------------------------------------------------------------------
- def update
- return if self.disposed?
- super
- if @data_sec != @time.sec
- @data_sec = @time.sec
- refresh
- end
- if self.x < $game_player.screen_x + @b_width and
- self.x + 240 > $game_player.screen_x - @b_width and
- self.y + 30 < $game_player.screen_y and
- self.y > $game_player.screen_y - @b_height
- self.opacity = 80
- else
- self.opacity = 255 if self.opacity < 255
- end
- dispose unless @time.sec_judge
- end
- end
- #==============================================================================
- class Game_System
- #--------------------------------------------------------------------------
- alias add_initialize_xr initialize
- def initialize
- add_initialize_xr
- @time_meters = []
- end
- #--------------------------------------------------------------------------
- def time_meters
- return @time_meters
- end
- #--------------------------------------------------------------------------
- def start_time(title="", min=0, switch_id=0, add=false)
- return if min == 0 or switch_id == 0
- for t in @time_meters
- if t.switch_id == switch_id
- t.add_count > 0 ? t.max_sec += Integer(min * 60) : t.sec += Integer(min * 60)
- return
- end
- end
- @time_meters.push(Time_Meter.new(title, min, switch_id, add))
- end
- #--------------------------------------------------------------------------
- def end_time(switch_id)
- for t in @time_meters
- if t.switch_id == switch_id
- @time_meters.delete(t)
- end
- end
- end
- #--------------------------------------------------------------------------
- alias old_update_xr update
- def update
- unless @time_meters.empty?
- for time in @time_meters
- time.update
- unless time.sec_judge
- @time_meters.delete(time)
- next
- end
- end
- end
- old_update_xr
- end
- end
- #==============================================================================
- #class Scene_Map
- class Scene_Map
- #--------------------------------------------------------------------------
- alias old_main_xr main
- def mains
- @time_window = []
- old_main_xr
- @time_window.each{|t| t.dispose}
- end
- #--------------------------------------------------------------------------
- alias old_update_xr update
- def update
- if @data_time != $game_system.time_meters
- @data_time = $game_system.time_meters.clone
- @time_window.each{|t| t.dispose}
- unless $game_system.time_meters.empty?
- for i in 0...$game_system.time_meters.size
- time = $game_system.time_meters[i]
- nx = X☆R::TM_WINDOW_X > 320 ? -240 : 240
- nx = i / 8 * nx
- x = X☆R::TM_WINDOW_X + nx ; y = i % 8 * 30 + X☆R::TM_WINDOW_Y
- @time_window[i] = Window_Tm.new(x, y, time)
- end
- end
- end
- unless @time_window.empty?
- for w in @time_window
- w.update
- @time_window.delete(w) if w.disposed?
- end
- end
- old_update_xr
- end
- end
- #==============================================================================
复制代码 |
|