查看: 2522|回复: 0

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

[复制链接]
梦石
0
星屑
235
在线时间
78 小时
注册时间
2010-7-1
回帖
46
发表于 2012-8-14 16:55:38 | 显示全部楼层 |阅读模式

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

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

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

腳本如下

  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Window_Info
  4. #------------------------------------------------------------------------------
  5. #  顯示遊戲資訊的視窗
  6. #==============================================================================

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

  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Scene_Menu
  4. #------------------------------------------------------------------------------
  5. #  選單畫面
  6. #==============================================================================

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部