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

Project1

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

[已经过期] 視窗裡的變數不會更新,求救!!!

[复制链接]

Lv1.梦旅人

梦石
0
星屑
200
在线时间
78 小时
注册时间
2010-7-1
帖子
58
跳转到指定楼层
1
发表于 2012-8-14 16:55:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我製做了一個使用變數和公共事件的時間,
並用腳本做了一個時間窗口,但數字不會動,只有關閉窗口再開啟數字才會變,
我想要讓它自動,該怎麼用?

腳本如下

RUBY 代码复制
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Window_Info
  4. #------------------------------------------------------------------------------
  5. #  顯示遊戲資訊的視窗
  6. #==============================================================================
  7.  
  8. class Window_Info < Window_Base
  9.   #--------------------------------------------------------------------------
  10.   # ● 初始化物件
  11.   #--------------------------------------------------------------------------
  12.   def initialize
  13.     super(0, 0, window_width, window_height)
  14.     refresh
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 取得視窗的寬度
  18.   #--------------------------------------------------------------------------
  19.   def window_width
  20.     Graphics.width * 3 / 4
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 取得視窗的高度
  24.   #--------------------------------------------------------------------------
  25.   def window_height
  26.     Graphics.height * 3 / 4
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # ● 重新整理
  30.   #--------------------------------------------------------------------------
  31.   def refresh
  32.     contents.clear
  33.     draw_currency_value(     second, Vocab::Second,
  34.     contents.width / 2, line_height * 2, contents.width / 6)
  35.     draw_currency_value(     minute, Vocab::Minute,
  36.     contents.width / 3, line_height * 2, contents.width / 6)
  37.     draw_currency_value(       hour,   Vocab::Hour,
  38.     contents.width / 6, line_height * 2, contents.width / 6)
  39.     draw_currency_value(       noon,            "",
  40.                      0, line_height * 2, contents.width / 6)
  41.     draw_currency_value(        day,    Vocab::Day,
  42.     contents.width / 3, line_height * 1, contents.width / 6)
  43.     draw_currency_value(       date,            "",
  44.     contents.width / 6, line_height * 1, contents.width / 6)
  45.     draw_currency_value(Vocab::Week,          week,
  46.                      0, line_height * 1, contents.width / 6)
  47.     draw_currency_value(      month,  Vocab::Month,
  48.     contents.width / 3, line_height * 0, contents.width / 6)
  49.     draw_currency_value(     season,            "",
  50.     contents.width / 6, line_height * 0, contents.width / 6)
  51.     draw_currency_value(       year,   Vocab::Year,
  52.                      0, line_height * 0, contents.width / 6)
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 取得時間
  56.   #--------------------------------------------------------------------------
  57.   def second #秒
  58.     $game_variables[1]
  59.   end
  60.  
  61.   def minute #分
  62.     $game_variables[2]
  63.   end
  64.  
  65.   def hour #時
  66.     $game_variables[3]
  67.   end
  68.  
  69.   def noon #午
  70.     if $game_variables[4] = 1
  71.       "上午" #Voacb::Beforenoon
  72.     else
  73.       "下午" #Voacb::Afternoon
  74.     end
  75.   end
  76.  
  77.   def day #天
  78.     $game_variables[5]
  79.   end
  80.  
  81.   def date #日
  82.     if $game_variables[6] = 1
  83.       "a" #Voacb::Sunday
  84.     elsif $game_variables[6] = 2
  85.       "b" #Voacb::Moonday
  86.     elsif $game_variables[6] = 3
  87.       "c" #Voacb::Skyday
  88.     elsif $game_variables[6] = 4
  89.       "d" #Voacb::Groundday
  90.     elsif $game_variables[6] = 5
  91.       "e" #Voacb::Lightday
  92.     else
  93.       "f" #oacb::Darkday
  94.     end
  95.   end
  96.  
  97.   def week #週
  98.     $game_variables[7]
  99.   end
  100.  
  101.   def month #月
  102.     $game_variables[8]
  103.   end
  104.  
  105.   def season #季
  106.     if $game_variables[9] = 1
  107.       "a" #Vocab::Warmseason
  108.     elsif $game_variables[9] = 2
  109.       "b" #Vocab::Hotseason
  110.     elsif $game_variables[9] = 3
  111.       "c" #Vocab::Coolseason
  112.     else
  113.       "d" #Vocab::Coldseason
  114.     end
  115.   end
  116.  
  117.   def year #年
  118.     $game_variables[10]
  119.   end
  120. end


RUBY 代码复制
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Scene_Menu
  4. #------------------------------------------------------------------------------
  5. #  選單畫面
  6. #==============================================================================
  7.  
  8. class Scene_Menu < Scene_MenuBase
  9.   #--------------------------------------------------------------------------
  10.   # ● 開始處理
  11.   #--------------------------------------------------------------------------
  12.   def start
  13.     super
  14.     create_command_window
  15.     create_gold_window
  16.     create_info_window
  17.     create_status_window
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● 生成指令視窗 #
  21.   #--------------------------------------------------------------------------
  22.   def create_command_window
  23.     @command_window = Window_MenuCommand.new
  24.     @command_window.x = (Graphics.width - @command_window.width) / 2
  25.     @command_window.y = 0 - 12
  26.     @command_window.set_handler(:item,      method(:command_item))
  27.     @command_window.set_handler(:skill,     method(:command_personal))
  28.     @command_window.set_handler(:equip,     method(:command_personal))
  29.     @command_window.set_handler(:status,    method(:command_personal))
  30.     @command_window.set_handler(:formation, method(:command_formation))
  31.     @command_window.set_handler(:save,      method(:command_save))
  32.     @command_window.set_handler(:game_end,  method(:command_game_end))
  33.     @command_window.set_handler(:cancel,    method(:return_scene))
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● 生成金錢視窗
  37.   #--------------------------------------------------------------------------
  38.   def create_gold_window
  39.     @gold_window = Window_Gold.new
  40.     @gold_window.x = 0
  41.     @gold_window.y = Graphics.height - @gold_window.height
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 生成資訊視窗
  45.   #--------------------------------------------------------------------------
  46.   def create_info_window
  47.     @info_window = Window_Info.new
  48.     @info_window.refresh
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● 生成狀態視窗 #
  52.   #--------------------------------------------------------------------------
  53.   def create_status_window
  54.     @status_window = Window_MenuStatus.new(-12, @command_window.height)
  55.     @status_window.hide
  56.     @status_window.opacity = 0
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # ● 指令“物品”
  60.   #--------------------------------------------------------------------------
  61.   def command_item
  62.     SceneManager.call(Scene_Item)
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● 指令“技能”“裝備”“狀態” #
  66.   #--------------------------------------------------------------------------
  67.   def command_personal
  68.     @status_window.show
  69.     @status_window.opacity += 63
  70.     @status_window.opacity += 127
  71.     @status_window.opacity += 191
  72.     @status_window.opacity += 255
  73.     @status_window.select_last
  74.     @status_window.activate
  75.     @status_window.set_handler(:ok,     method(:on_personal_ok))
  76.     @status_window.set_handler(:cancel, method(:on_personal_cancel))
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 指令“整隊” #
  80.   #--------------------------------------------------------------------------
  81.   def command_formation
  82.     @status_window.show
  83.     @status_window.select_last
  84.     @status_window.activate
  85.     @status_window.set_handler(:ok,     method(:on_formation_ok))
  86.     @status_window.set_handler(:cancel, method(:on_formation_cancel))
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # ● 指令“存檔”
  90.   #--------------------------------------------------------------------------
  91.   def command_save
  92.     SceneManager.call(Scene_Save)
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # ● 指令“結束游戲”
  96.   #--------------------------------------------------------------------------
  97.   def command_game_end
  98.     SceneManager.call(Scene_End)
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 個人指令“確定”
  102.   #--------------------------------------------------------------------------
  103.   def on_personal_ok
  104.     case @command_window.current_symbol
  105.     when :skill
  106.       SceneManager.call(Scene_Skill)
  107.     when :equip
  108.       SceneManager.call(Scene_Equip)
  109.     when :status
  110.       SceneManager.call(Scene_Status)
  111.     end
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 個人指令“取消” #
  115.   #--------------------------------------------------------------------------
  116.   def on_personal_cancel
  117.     @status_window.unselect
  118.     @status_window.hide
  119.     @command_window.activate
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● 整隊“確定”
  123.   #--------------------------------------------------------------------------
  124.   def on_formation_ok
  125.     if @status_window.pending_index >= 0
  126.       $game_party.swap_order(@status_window.index,
  127.                              @status_window.pending_index)
  128.       @status_window.pending_index = -1
  129.       @status_window.redraw_item(@status_window.index)
  130.     else
  131.       @status_window.pending_index = @status_window.index
  132.     end
  133.     @status_window.activate
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ● 整隊“取消” #
  137.   #--------------------------------------------------------------------------
  138.   def on_formation_cancel
  139.     if @status_window.pending_index >= 0
  140.       @status_window.pending_index = -1
  141.       @status_window.activate
  142.     else
  143.       @status_window.unselect
  144.       @status_window.hide
  145.       @command_window.activate
  146.     end
  147.   end
  148. end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-5-21 06:50

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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