查看: 2480|回复: 0

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

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

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

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

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

腳本如下

[pre lang="ruby" line="1"]#encoding:utf-8
#==============================================================================
# ■ Window_Info
#------------------------------------------------------------------------------
#  顯示遊戲資訊的視窗
#==============================================================================

class Window_Info < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化物件
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, window_width, window_height)
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 取得視窗的寬度
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width * 3 / 4
  end
  #--------------------------------------------------------------------------
  # ● 取得視窗的高度
  #--------------------------------------------------------------------------
  def window_height
    Graphics.height * 3 / 4
  end
  #--------------------------------------------------------------------------
  # ● 重新整理
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_currency_value(     second, Vocab::Second,
    contents.width / 2, line_height * 2, contents.width / 6)
    draw_currency_value(     minute, Vocab::Minute,
    contents.width / 3, line_height * 2, contents.width / 6)
    draw_currency_value(       hour,   Vocab::Hour,
    contents.width / 6, line_height * 2, contents.width / 6)
    draw_currency_value(       noon,            "",
                     0, line_height * 2, contents.width / 6)
    draw_currency_value(        day,    Vocab::Day,
    contents.width / 3, line_height * 1, contents.width / 6)
    draw_currency_value(       date,            "",
    contents.width / 6, line_height * 1, contents.width / 6)
    draw_currency_value(Vocab::Week,          week,
                     0, line_height * 1, contents.width / 6)
    draw_currency_value(      month,  Vocab::Month,
    contents.width / 3, line_height * 0, contents.width / 6)
    draw_currency_value(     season,            "",
    contents.width / 6, line_height * 0, contents.width / 6)
    draw_currency_value(       year,   Vocab::Year,
                     0, line_height * 0, contents.width / 6)
  end
  #--------------------------------------------------------------------------
  # ● 取得時間
  #--------------------------------------------------------------------------
  def second #秒
    $game_variables[1]
  end
  
  def minute #分
    $game_variables[2]
  end
  
  def hour #時
    $game_variables[3]
  end
  
  def noon #午
    if $game_variables[4] = 1
      "上午" #Voacb::Beforenoon
    else
      "下午" #Voacb::Afternoon
    end
  end
  
  def day #天
    $game_variables[5]
  end
  
  def date #日
    if $game_variables[6] = 1
      "a" #Voacb::Sunday
    elsif $game_variables[6] = 2
      "b" #Voacb::Moonday
    elsif $game_variables[6] = 3
      "c" #Voacb::Skyday
    elsif $game_variables[6] = 4
      "d" #Voacb::Groundday
    elsif $game_variables[6] = 5
      "e" #Voacb::Lightday
    else
      "f" #oacb::Darkday
    end
  end
  
  def week #週
    $game_variables[7]
  end
  
  def month #月
    $game_variables[8]
  end
  
  def season #季
    if $game_variables[9] = 1
      "a" #Vocab::Warmseason
    elsif $game_variables[9] = 2
      "b" #Vocab::Hotseason
    elsif $game_variables[9] = 3
      "c" #Vocab::Coolseason
    else
      "d" #Vocab::Coldseason
    end
  end
  
  def year #年
    $game_variables[10]
  end
end[/pre]

[pre lang="ruby" line="1"]#encoding:utf-8
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
#  選單畫面
#==============================================================================

class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● 開始處理
  #--------------------------------------------------------------------------
  def start
    super
    create_command_window
    create_gold_window
    create_info_window
    create_status_window
  end
  #--------------------------------------------------------------------------
  # ● 生成指令視窗 #
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_MenuCommand.new
    @command_window.x = (Graphics.width - @command_window.width) / 2
    @command_window.y = 0 - 12
    @command_window.set_handler(:item,      method(:command_item))
    @command_window.set_handler(:skill,     method(:command_personal))
    @command_window.set_handler(:equip,     method(:command_personal))
    @command_window.set_handler(:status,    method(:command_personal))
    @command_window.set_handler(:formation, method(:command_formation))
    @command_window.set_handler(:save,      method(:command_save))
    @command_window.set_handler(:game_end,  method(:command_game_end))
    @command_window.set_handler(:cancel,    method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # ● 生成金錢視窗
  #--------------------------------------------------------------------------
  def create_gold_window
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = Graphics.height - @gold_window.height
  end
  #--------------------------------------------------------------------------
  # ● 生成資訊視窗
  #--------------------------------------------------------------------------
  def create_info_window
    @info_window = Window_Info.new
    @info_window.refresh
  end
  #--------------------------------------------------------------------------
  # ● 生成狀態視窗 #
  #--------------------------------------------------------------------------
  def create_status_window
    @status_window = Window_MenuStatus.new(-12, @command_window.height)
    @status_window.hide
    @status_window.opacity = 0
  end
  #--------------------------------------------------------------------------
  # ● 指令“物品”
  #--------------------------------------------------------------------------
  def command_item
    SceneManager.call(Scene_Item)
  end
  #--------------------------------------------------------------------------
  # ● 指令“技能”“裝備”“狀態” #
  #--------------------------------------------------------------------------
  def command_personal
    @status_window.show
    @status_window.opacity += 63
    @status_window.opacity += 127
    @status_window.opacity += 191
    @status_window.opacity += 255
    @status_window.select_last
    @status_window.activate
    @status_window.set_handler(:ok,     method(:on_personal_ok))
    @status_window.set_handler(:cancel, method(:on_personal_cancel))
  end
  #--------------------------------------------------------------------------
  # ● 指令“整隊” #
  #--------------------------------------------------------------------------
  def command_formation
    @status_window.show
    @status_window.select_last
    @status_window.activate
    @status_window.set_handler(:ok,     method(:on_formation_ok))
    @status_window.set_handler(:cancel, method(:on_formation_cancel))
  end
  #--------------------------------------------------------------------------
  # ● 指令“存檔”
  #--------------------------------------------------------------------------
  def command_save
    SceneManager.call(Scene_Save)
  end
  #--------------------------------------------------------------------------
  # ● 指令“結束游戲”
  #--------------------------------------------------------------------------
  def command_game_end
    SceneManager.call(Scene_End)
  end
  #--------------------------------------------------------------------------
  # ● 個人指令“確定”
  #--------------------------------------------------------------------------
  def on_personal_ok
    case @command_window.current_symbol
    when :skill
      SceneManager.call(Scene_Skill)
    when :equip
      SceneManager.call(Scene_Equip)
    when :status
      SceneManager.call(Scene_Status)
    end
  end
  #--------------------------------------------------------------------------
  # ● 個人指令“取消” #
  #--------------------------------------------------------------------------
  def on_personal_cancel
    @status_window.unselect
    @status_window.hide
    @command_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 整隊“確定”
  #--------------------------------------------------------------------------
  def on_formation_ok
    if @status_window.pending_index >= 0
      $game_party.swap_order(@status_window.index,
                             @status_window.pending_index)
      @status_window.pending_index = -1
      @status_window.redraw_item(@status_window.index)
    else
      @status_window.pending_index = @status_window.index
    end
    @status_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 整隊“取消” #
  #--------------------------------------------------------------------------
  def on_formation_cancel
    if @status_window.pending_index >= 0
      @status_window.pending_index = -1
      @status_window.activate
    else
      @status_window.unselect
      @status_window.hide
      @command_window.activate
    end
  end
end[/pre]
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部