Project1

标题: 时间改成24小时制 [打印本页]

作者: xx小虾米xx    时间: 2012-3-1 12:02
标题: 时间改成24小时制
本帖最后由 xx小虾米xx 于 2012-3-1 08:27 编辑

   #计算时间
    if $game_switches[$time_date_running] == true
      @total_sec = Graphics.frame_count
      if @total_sec % $min_rate ==0
        $game_variables[$min] += 1
      end
      if $game_variables[$min] >= $hour_rate + 1
        $game_variables[$min] = 1
        $game_variables[$hour] += 1
        $hour_count += 1
      end
      if $game_variables[$hour] >= $day_rate + 1
        $game_variables[$hour] = 1
        $game_variables[$day] += 1
        $game_variables[$week] += 1
        if $game_variables[$week] == 8
          $game_variables[$week] = 1
        end
      end
      if $game_variables[$day] >= $month_rate + 1
        $game_variables[$day] = 1
        $game_variables[$month] += 1
      end
      if $game_variables[$month] >= $year_rate + 1
        $game_variables[$month] = 1
        $game_variables[$year] += 1
      end
    end


‘‘──xx小虾米xx于2012-3-1 08:17补充以下内容

    #定义显示[时]
    self.contents.font.color = hour_color
    self.contents.font.size = $hour_font_size
    #$hour_x = $day_x + $day_space
    case $game_variables[$hour]
    when 1
      hourtxt = "子时"#11pm ~ 1am
    when 2
      hourtxt = "丑时"#1am ~ 3am
    when 3
      hourtxt = "寅时"#3am ~ 5am
    when 4
      hourtxt = "卯时"#5am ~ 7am
    when 5
      hourtxt = "辰时"#7am ~ 9am
    when 6
      hourtxt = "巳时"#9am ~ 11am
    when 7
      hourtxt = "午时"#11am ~ 1pm
    when 8
      hourtxt = "未时"#1pm ~ 3pm
    when 9
      hourtxt = "申时"#3pm ~ 5pm
    when 10
      hourtxt = "酉时"#5pm ~ 7pm
    when 11
      hourtxt = "戌时"#7pm ~ 9pm
    when 12
      hourtxt = "亥时"#9pm ~ 11pm
    end
’’

我如果想改成24小时制的话。。。这样写可以不???。。。

  #定义显示[时]
    self.contents.font.color = hour_color
    self.contents.font.size = $hour_font_size
    #$hour_x = $day_x + $day_space
    case $game_variables[$hour]
    when 1
      hourtxt = "01am"#11pm ~ 1am
    when 2
      hourtxt = "02am"#1am ~ 3am
    when 3
      hourtxt = "03am"#3am ~ 5am
    when 4
      hourtxt = "04am"#5am ~ 7am
    when 5
      hourtxt = "05am"#7am ~ 9am
    when 6
      hourtxt = "06am"#9am ~ 11am
    when 7
      hourtxt = "07am"#11am ~ 1pm
    when 8
      hourtxt = "08am"#1pm ~ 3pm
    when 9
      hourtxt = "09am"#3pm ~ 5pm
    when 10
      hourtxt = "10am"#5pm ~ 7pm
    when 11
      hourtxt = "11am"#7pm ~ 9pm
    when 12
      hourtxt = "12am"#9pm ~ 11pm
    when 13
      hourtxt = "01Pm"#9pm ~ 11pm
    when 14
      hourtxt = "02pm"#9pm ~ 11pm
    when 15
      hourtxt = "03pm"#9pm ~ 11pm
。。。。。。。。。。。。。。。。
。。。。。。。。。。。。。
一直到
when 24
      hourtxt = "12pm"#9pm ~ 11pm
    end



是这样写吗?????????????
dsu_plus_rewardpost_czw
作者: 526832541    时间: 2012-3-1 13:22
  1. #==============================================================================
  2. # ■ Window_PlayTime
  3. #------------------------------------------------------------------------------
  4. #  メニュー画面でプレイ時間を表示するウィンドウです。
  5. #==============================================================================

  6. class Window_PlayTime < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● オブジェクト初期化
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 0, 160, 130)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.     refresh
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # ● リフレッシュ
  17.   #--------------------------------------------------------------------------
  18.   #--------------------------------------------------------------------------
  19. # ● 刷新
  20. #--------------------------------------------------------------------------
  21. def refresh
  22.   self.contents.clear
  23.   time = Time.now
  24.   text = time.strftime("%Y年%m月%d日")
  25.   text1 = time.strftime("%H点%M分%S秒")
  26.   text2 = time.strftime("星期" + ["日", "一", "二", "三", "四", "五", "六"][time.wday])
  27.   self.contents.font.color = text_color(1)
  28.   self.contents.draw_text(4, 0, 120, 20, text, 1)
  29.   self.contents.font.color = text_color(1)
  30.   self.contents.draw_text(4, 32, 120, 20, text1, 1)
  31.   self.contents.font.color = text_color(1)
  32.   self.contents.draw_text(4, 56, 120, 20, text2, 1)
  33.   @total_sec = Graphics.frame_count / Graphics.frame_rate
  34.   hour = @total_sec / 60 / 60
  35.   min = @total_sec / 60 % 60
  36.   sec = @total_sec % 60
  37.   text = sprintf("%02d小时%02d分%02d秒", hour, min, sec)
  38.   self.contents.font.color = text_color(1)
  39.   self.contents.draw_text(4, 82, 120, 20, text, 1)
  40. end
  41.   #--------------------------------------------------------------------------
  42.   # ● フレーム更新
  43.   #--------------------------------------------------------------------------
  44.   def update
  45.     super
  46.     if Graphics.frame_count / Graphics.frame_rate != @total_sec
  47.       refresh
  48.     end
  49.   end
  50. end
复制代码
自己再改改吧~LZ应该能看懂吧




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