赞 | 0 |
VIP | 40 |
好人卡 | 2 |
积分 | 1 |
经验 | 10932 |
最后登录 | 2016-5-17 |
在线时间 | 462 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 462 小时
- 注册时间
- 2007-7-30
- 帖子
- 643
|
本帖最后由 david50407 于 2010-11-20 14:55 编辑
- #==============================================================================
- # ■ WShow
- #------------------------------------------------------------------------------
- # 显示特定值的视窗。
- #==============================================================================
- class WShow < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化视窗
- #--------------------------------------------------------------------------
- def initialize(*args)
- if args[0].is_a?(Hash)
- width = args[0][:width]
- height = args[0][:height]
- args.shift
- end
- @kinds = args
- width = 160 if width.nil?
- height = 32 * args.length + 32 if height.nil?
- super(0, 0, width, height)
- self.contents = Bitmap.new(width - 32, height - 32)
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 更新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- x = 4
- y = 0
- for c in @kinds
- case c
- when :gold
- cx = contents.text_size($data_system.words.gold).width
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y, width - cx - 42, 32, $game_party.gold.to_s, 2)
- self.contents.font.color = system_color
- self.contents.draw_text(width - 36 - cx, y, cx, 32, $data_system.words.gold, 2)
- y += 32
-
- when :playtime
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, width - 40, 32, "游戏时间")
- @total_sec = Graphics.frame_count / Graphics.frame_rate
- hour = @total_sec / 60 / 60
- min = @total_sec / 60 % 60
- sec = @total_sec % 60
- text = sprintf("%02d:%02d:%02d", hour, min, sec)
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y + 32, width - 40, 32, text, 2)
- y += 64
-
- when :steps
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 120, 32, "步数")
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y + 32, 120, 32, $game_party.steps.to_s, 2)
- y += 64
-
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- if @kinds.include?(:playtime)
- if Graphics.frame_count / Graphics.frame_rate != @total_sec
- refresh
- end
- end
- end
- end
复制代码 用法...
@window = WShow.new({:height => 128 + 32}, :steps, :gold)
第一个参数可以是Hash {:height => 128, :width => 180}
也可以不是
剩下的参数是 :steps :gold :playtime |
|