设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2131|回复: 3
打印 上一主题 下一主题

[已经解决] 菜单的时间显示问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
115
在线时间
132 小时
注册时间
2009-9-16
帖子
60
跳转到指定楼层
1
发表于 2010-8-8 12:17:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
怎么将这个脚本的时间显示弄进这个菜单里?

以下菜单脚本
  1. class Window_Command_New < Window_Selectable
  2.   def initialize(actors=4,enemynums=0)
  3.     super(438, 20, 172, 160)
  4.     self.contents = Bitmap.new(width - 32, height - 32)
  5.     self.opacity = HS::OPACITY
  6.     @commands = ["精灵","道具","技能","加点","装备","队列","任务","系统"]
  7.     @item_max = 8
  8.     @column_max = 2
  9.     @actors = actors
  10.     @enemynums = enemynums
  11.     draw_item(0, @actors==0 ? disabled_color : normal_color)
  12.     draw_item(1, normal_color)
  13.     draw_item(2, @actors==0 ? disabled_color : normal_color)
  14.     draw_item(3, @actors==0 ? disabled_color : normal_color)
  15.     draw_item(4, @actors==0 ? disabled_color : normal_color)
  16.     draw_item(5, @actors==0 ? disabled_color : normal_color)
  17.     draw_item(6, normal_color)
  18.     draw_item(7, normal_color)
  19.     self.index = 0
  20.   end
  21.   def draw_item(index, color)
  22.     self.contents.font.color = color
  23.     x = 4 + index % 2 * 70
  24.     y = index / 2 * 32
  25.     rect = Rect.new(x, y, 64, 32)
  26.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  27.     self.contents.draw_text(rect, @commands[index], 1)
  28.   end
  29.   def update_cursor_rect
  30.     x = 4 + index % 2 * 70
  31.     y = index / 2 * 32
  32.     self.cursor_rect.set(x, y, 64, 32)
  33.   end
  34. end

  35. class Scene_Menu
  36.   def initialize(menu_index = 0)
  37.     @menu_index = menu_index
  38.   end
  39.   def main
  40. #   check_enemy_in_map($game_player.x,$game_player.y)
  41.     cmd = Window_Command_New.new($game_party.actors.size)
  42.     cmd.index = @menu_index
  43.     Graphics.transition
  44.     loop do
  45.       Graphics.update
  46.       Input.update
  47.       cmd.update
  48.       if Input.trigger?(Input::B)
  49.         $game_system.se_play($data_system.cancel_se)
  50.         $scene = Scene_Map.new
  51.       end
  52.       if Input.trigger?(Input::C)
  53.         case cmd.index
  54.         when 0
  55.           $game_system.se_play($data_system.decision_se)
  56.           $scene = Scene_Status.new
  57.         when 1
  58.           $game_system.se_play($data_system.decision_se)
  59.           $scene = Scene_Item.new
  60.         when 2
  61.           $game_system.se_play($data_system.decision_se)
  62.           $scene = Scene_Skill.new
  63.         when 3
  64.           $game_system.se_play($data_system.decision_se)
  65.           $scene = Scene_Lvup.new
  66.         when 4
  67.           $game_system.se_play($data_system.decision_se)
  68.           $scene = Scene_Equip.new
  69.         when 5
  70.           $game_system.se_play($data_system.decision_se)
  71.           $scene = Scene_Change_Turn.new
  72.         when 6
  73.           $game_system.se_play($data_system.decision_se)
  74.           $scene = Scene_Task.new
  75.         when 7
  76.           $game_system.se_play($data_system.decision_se)
  77.           $scene = Scene_Save.new
  78.         end
  79.       end
  80.       if $scene != self
  81.         break
  82.       end
  83.     end
  84.     Graphics.freeze
  85.     cmd.dispose
  86.   end
  87. end
复制代码
下面时间显示脚本
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================
  4. #==============================================================================
  5. # ■ Window_PlayTime
  6. #------------------------------------------------------------------------------
  7. #  菜单画面显示游戏时间的窗口。
  8. #==============================================================================

  9. class Window_PlayTime < Window_Base
  10.   #--------------------------------------------------------------------------
  11.   # ● 初始化对像
  12.   #--------------------------------------------------------------------------
  13.   def initialize
  14.     super(0, 0, 160, 128 )
  15.     self.contents = Bitmap.new(width - 32, height - 32)
  16.     refresh
  17.   end
  18.   #--------------------------------------------------------------------------
  19.   # ● 刷新
  20.   #--------------------------------------------------------------------------
  21.   def refresh
  22.     self.contents.clear
  23.     self.contents.font.color = system_color
  24.     self.contents.draw_text(4, -4, 120, 32, "当前时间")
  25.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  26.     t = Time.now
  27. $game_variables[204] = t.wday  # 星期
  28. $game_variables[208] = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"][$game_variables[204]]
  29. text = sprintf("%02d:%02d:%02d", t.hour, t.min, t.sec)
  30. text2 = sprintf("%02d.%02d.%02d", t.year, t.month, t.day)
  31. text3 = sprintf($game_variables[208])
  32. self.contents.font.color = normal_color
  33.     self.contents.draw_text(4, 24, 110, 32, text2, 2)
  34.     self.contents.draw_text(-25, 48, 110, 32, text3, 2)
  35.     self.contents.draw_text(-3, 72, 110, 32, text, 2)
  36.     end
  37.   #--------------------------------------------------------------------------
  38.   # ● 刷新画面
  39.   #--------------------------------------------------------------------------
  40.   def update
  41.     super
  42.     if Graphics.frame_count / Graphics.frame_rate != @total_sec
  43.       refresh
  44.     end
  45.   end
  46. end
  47. #==============================================================================
  48. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  49. #==============================================================================
复制代码
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
9 小时
注册时间
2010-7-15
帖子
18
2
发表于 2010-8-8 14:03:22 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
115
在线时间
132 小时
注册时间
2009-9-16
帖子
60
3
 楼主| 发表于 2010-8-8 15:18:43 | 只看该作者
回复 DLawliet 的帖子
太谢谢你啊!!!!小弟感激不尽!

   
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
46
在线时间
33 小时
注册时间
2012-8-25
帖子
93
4
发表于 2012-10-8 21:42:33 | 只看该作者
同问~#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
#  处理菜单画面的类。
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     menu_index : 命令光标的初期位置
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # ● 主处理
  #--------------------------------------------------------------------------
  def main
    # 生成命令窗口
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "角色状态"
    s5 = "保存"
    s6 = "结束冒险"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.index = @menu_index
    # 同伴人数为 0 的情况下
    if $game_party.actors.size == 0
      # 物品、特技、装备、状态无效化
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    # 禁止存档的情况下
    if $game_system.save_disabled
      # 存档无效
      @command_window.disable_item(4)
    end
    # 生成游戏时间窗口
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 224
    # 生成步数窗口
    @steps_window = Window_Steps.new
    @steps_window.x = 0
    @steps_window.y = 320
    # 生成金钱窗口
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = 416
    # 生成状态窗口
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    # 执行过渡
    Graphics.transition
    # 主循环
    loop do
      # 刷新游戏画面
      Graphics.update
      # 刷新输入信息
      Input.update
      # 刷新画面
      update
      # 如果切换画面就中断循环
      if $scene != self
        break
      end
    end
    # 准备过渡
    Graphics.freeze
    # 释放窗口
    @command_window.dispose
    @playtime_window.dispose
    @steps_window.dispose
    @gold_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    # 刷新窗口
    @command_window.update
    @playtime_window.update
    @steps_window.update
    @gold_window.update
    @status_window.update
    # 命令窗口被激活的情况下: 调用 update_command
    if @command_window.active
      update_command
      return
    end
    # 状态窗口被激活的情况下: 调用 update_status
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (命令窗口被激活的情况下)
  #--------------------------------------------------------------------------
  def update_command
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 切换的地图画面
      $scene = Scene_Map.new
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 同伴人数为 0、存档、游戏结束以外的场合
      if $game_party.actors.size == 0 and @command_window.index < 4
        # 演奏冻结 SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # 命令窗口的光标位置分支
      case @command_window.index
      when 0  # 物品
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 切换到物品画面
        $scene = Scene_Item.new
      when 1  # 特技
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 激活状态窗口
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # 装备
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 激活状态窗口
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3  # 状态
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 激活状态窗口
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4  # 存档
        # 禁止存档的情况下
        if $game_system.save_disabled
          # 演奏冻结 SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 切换到存档画面
        $scene = Scene_Save.new
      when 5  # 游戏结束
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 切换到游戏结束画面
        $scene = Scene_End.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (状态窗口被激活的情况下)
  #--------------------------------------------------------------------------
  def update_status
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 激活命令窗口
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 命令窗口的光标位置分支
      case @command_window.index
      when 1  # 特技
        # 本角色的行动限制在 2 以上的情况下
        if $game_party.actors[@status_window.index].restriction >= 2
          # 演奏冻结 SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 切换到特技画面
        $scene = Scene_Skill.new(@status_window.index)
      when 2  # 装备
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 切换的装备画面
        $scene = Scene_Equip.new(@status_window.index)
      when 3  # 状态
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 切换到状态画面
        $scene = Scene_Status.new(@status_window.index)
      end
      return
    end
  end
end

时间脚本t = Time.now
p sprintf("%d年%d月%d日%d时%d分%d秒",
          t.year, t.mon, t.day,
          t.hour, t.min, t.sec)

评分

参与人数 1星屑 -260 收起 理由
hys111111 -260 挖坟(26个月)

查看全部评分

[
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-8 13:11

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表