Project1

标题: [小白技术]RMVA菜单中显示游戏时间简单版 [打印本页]

作者: z12508186    时间: 2012-2-6 15:26
标题: [小白技术]RMVA菜单中显示游戏时间简单版
本帖最后由 z12508186 于 2012-2-7 16:04 编辑

废话不多说,先上效果图。

这是从RMXP中移植过来的。

在脚本"Window_Gold"中的第13行。将fitting_height(1)中的1改成2(不然不够高度显示)
  1.     super(0, 0, window_width, fitting_height(2))#金钱与时间窗口的高度
复制代码
再来就是从第18行下面插入以下代码即可。
  1.     self.contents.font.color = system_color          #显示“游戏时间”这几个字的颜色
  2.     self.contents.draw_text(4, 12, 120, 32, "游戏时间") #()中分别显示“游戏时间”这几个字的位置
  3.     @total_sec = Graphics.frame_count / Graphics.frame_rate #游戏时间的取得
  4.     hour = @total_sec / 60 / 60
  5.     min = @total_sec / 60 % 60
  6.     sec = @total_sec % 60
  7.     text = sprintf("%02d:%02d:%02d", hour, min, sec)    #游戏时间的显示方式
  8.     self.contents.font.color = normal_color                #显示“游戏时间”的颜色
  9.     self.contents.draw_text(4, 27, 120, 32, text, 2)  #()中分别显示“游戏时间”的位置
复制代码
小白初试的改脚本。。。轻拍!

谢谢“星尘泪”的提醒。。已更正。。但后来又发现了更大的问题。。就是使用以上脚本会导致在商店买东西时。。显示金钱时也会把时间显示出来。。显示错位。。哈
新图如下:

这是显示系统当前时间(也就是时钟功能。。哈。。全屏时也不怕玩过头了)
  1.   #==============================================================================
  2. # ■ Window_Timer
  3. #------------------------------------------------------------------------------
  4. #  显示系统当前时间的窗口
  5. #==============================================================================

  6. class Window_Timer < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对象
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 0, window_width, fitting_height(3))
  12.     refresh
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # ● 获取窗口的宽度
  16.   #--------------------------------------------------------------------------
  17.   def window_width
  18.     return 160
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # ● 刷新
  22.   #--------------------------------------------------------------------------
  23.   def refresh
  24.     self.contents.clear
  25.     self.contents.font.color = system_color
  26.     self.contents.draw_text(0, 0, 120, 32, "当前时间") #显示文本位置,我没有细调。。
  27.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  28.     t = Time.now
  29.     $game_variables[204] = t.wday  # 星期
  30.     $game_variables[208] = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"][$game_variables[204]]
  31.     text = sprintf("%02d:%02d:%02d", t.hour, t.min, t.sec)
  32.     text2 = sprintf("%02d.%02d.%02d", t.year, t.month, t.day)
  33.     text3 = sprintf($game_variables[208])
  34.     self.contents.font.color = normal_color
  35.     self.contents.draw_text(0, 20, 110, 32, text2, 2)
  36.     self.contents.draw_text(-25, 40, 110, 32, text3, 2)
  37.     self.contents.draw_text(-3, 60, 110, 32, text, 2)
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ● 打开窗口
  41.   #--------------------------------------------------------------------------
  42.   def open
  43.     refresh
  44.     super
  45.   end
  46. end
复制代码
之后是游戏时间
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Window_PlayTime
  4. #------------------------------------------------------------------------------
  5. #  显示游戏时间的窗口
  6. #==============================================================================

  7. class Window_PlayTime < Window_Base
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化对象
  10.   #--------------------------------------------------------------------------
  11.   def initialize
  12.     super(0, 0, window_width, fitting_height(2))#游戏时间窗口的高度
  13.     refresh
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # ● 获取窗口的宽度
  17.   #--------------------------------------------------------------------------
  18.   def window_width
  19.     return 160 #游戏时间窗口的宽度
  20.   end
  21.   #--------------------------------------------------------------------------
  22.   # ● 刷新
  23.   #--------------------------------------------------------------------------
  24.   def refresh
  25.     contents.clear
  26.     self.contents.font.color = system_color
  27.     self.contents.draw_text(0, 0, 120, 32, "游戏时间")
  28.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  29.     hour = @total_sec / 60 / 60
  30.     min = @total_sec / 60 % 60
  31.     sec = @total_sec % 60
  32.     text = sprintf("%02d:%02d:%02d", hour, min, sec)
  33.     self.contents.font.color = normal_color
  34.     self.contents.draw_text(0, 20, 120, 32, text, 2)
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 打开窗口
  38.   #--------------------------------------------------------------------------
  39.   def open
  40.     refresh
  41.     super
  42.   end
  43. end
复制代码
再之后是如何将上面的窗口创建出来并打开啦:
在Scene_Menu的第17行下插入
  1.      create_timer_window  
复制代码
再看看上面几行代码就不能发现。这是创建新的窗口用的。。当然。。这只是开头。。它还必须引用下面的代码:
  1.   #--------------------------------------------------------------------------
  2.   # ● 生成金钱窗口
  3.   #--------------------------------------------------------------------------
  4.   def create_gold_window
  5.     @gold_window = Window_Gold.new
  6.     @gold_window.x = 0
  7.     @gold_window.y = Graphics.height - @gold_window.height
  8.   end
  9.   #--------------------------------------------------------------------------
  10.   # ● 生成游戏时间窗口
  11.   #--------------------------------------------------------------------------
  12.   def create_playtime_window
  13.     @playtime_window = Window_PlayTime.new
  14.     @playtime_window.x = 0
  15.     @playtime_window.y = Graphics.height - @gold_window.height - @playtime_window.height
  16.   end
  17.    #--------------------------------------------------------------------------
  18.   # ● 生成系统时间窗口
  19.   #--------------------------------------------------------------------------
  20.   def create_timer_window
  21.     @timer_window = Window_Timer.new
  22.     @timer_window.x = 0
  23.     @timer_window.y = Graphics.height - @gold_window.height - @playtime_window.height - @timer_window.height
  24.   end
复制代码
在“生成金钱窗口”下添加上面的内容即可。。。嘿嘿。。
作者: 星尘泪    时间: 2012-2-6 17:11
提示: 作者被禁止或删除 内容自动屏蔽
作者: z12508186    时间: 2012-2-7 16:04
星尘泪 发表于 2012-2-6 17:11
- -第18行错误

多谢提醒,已经更正了。。哈哈
作者: xuzhengchi    时间: 2012-2-7 17:25
LZ你这用的是什么字体?
作者: z12508186    时间: 2012-2-7 23:40
xuzhengchi 发表于 2012-2-7 17:25
LZ你这用的是什么字体?

这是华康少女文字。
作者: 杰总    时间: 2012-2-11 23:49
那么麻烦,不如把改好后的Window_Gold发出来就好了嘛!
作者: xmheart    时间: 2012-2-13 21:19
经过试验,失败啊,LZ。你能不能发个完整的啊,我跟着弄也不行
作者: z12508186    时间: 2012-2-14 09:43
本帖最后由 z12508186 于 2012-2-14 14:52 编辑

http://115.com/file/dp2kufav#LS 可以参考这个脚本。。但要安装字体哈。。。。

作者: 杰总    时间: 2012-2-14 12:51
lz发一个完整的,或着发一个范例,不难吧?
作者: z12508186    时间: 2012-2-14 14:38
杰总 发表于 2012-2-14 12:51
lz发一个完整的,或着发一个范例,不难吧?

{:1_10:}@  8楼的就是了。。。哈


‘‘

游戏时间脚本
抱歉。。已更新


──z12508186于2012-2-14 14:51补充以上内容’’
作者: 杰总    时间: 2012-2-17 20:20
谢啦!不过咋没日期呢?我比较重视这个……
作者: z12508186    时间: 2012-2-18 08:58
杰总 发表于 2012-2-17 20:20
谢啦!不过咋没日期呢?我比较重视这个……

在我的范例外有讲的~~{:1_9:}@,那里作了更改都有注明的。。请留意一下~
作者: poiuy12348609    时间: 2012-7-13 17:01
第18行還是錯誤
作者: talone    时间: 2012-8-1 04:14
谢谢,你的劳动成果我拿走了,幸苦了!
作者: qsqs1590    时间: 2012-8-12 00:57
这还是有出错阿
这个
  1.      create_timer_window
复制代码

插下去只会显现系统时间
但你还有游戏时间要显现阿
所以要在第17行那插入成
  1.     create_timer_window
  2.     create_playtime_window
复制代码

这样才换显现县两个
整体而言是这样,加上楼主的两个时间脚本再改Scene_Menu,修改这个大概是9~57行
  1.   #--------------------------------------------------------------------------
  2.   # ● 开始处里
  3.   #--------------------------------------------------------------------------
  4.   def start
  5.     super
  6.     create_command_window
  7.     create_gold_window
  8.     create_status_window
  9.     create_timer_window
  10.     create_playtime_window
  11.   end
  12.   #--------------------------------------------------------------------------
  13.   # ● 生成指令视窗
  14.   #--------------------------------------------------------------------------
  15.   def create_command_window
  16.     @command_window = Window_MenuCommand.new
  17.     @command_window.set_handler(:item,      method(:command_item))
  18.     @command_window.set_handler(:skill,     method(:command_personal))
  19.     @command_window.set_handler(:equip,     method(:command_personal))
  20.     @command_window.set_handler(:status,    method(:command_personal))
  21.     @command_window.set_handler(:formation, method(:command_formation))
  22.     @command_window.set_handler(:save,      method(:command_save))
  23.     @command_window.set_handler(:game_end,  method(:command_game_end))
  24.     @command_window.set_handler(:cancel,    method(:return_scene))
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 生成金钱窗口
  28.   #--------------------------------------------------------------------------
  29.   def create_gold_window
  30.     @gold_window = Window_Gold.new
  31.     @gold_window.x = 0
  32.     @gold_window.y = Graphics.height - @gold_window.height
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 生成游戏时间窗口
  36.   #--------------------------------------------------------------------------
  37.   def create_playtime_window
  38.     @playtime_window = Window_PlayTime.new
  39.     @playtime_window.x = 0
  40.     @playtime_window.y = Graphics.height - @gold_window.height - @playtime_window.height
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ● 生成系统时间窗口
  44.   #--------------------------------------------------------------------------
  45.   def create_timer_window
  46.     @timer_window = Window_Timer.new
  47.     @timer_window.x = 0
  48.     @timer_window.y = Graphics.height - @gold_window.height - @playtime_window.height - @timer_window.height
  49.   end
复制代码





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