Project1

标题: 啊喏~关于窗口显示与消失... [打印本页]

作者: larbi    时间: 2009-5-15 03:37
标题: 啊喏~关于窗口显示与消失...
http://rpg.blue/viewthread.php?tid=63807&ntime=2009%2D5%2D14+19%3A14%3A29

请教一下各位大大~~~>.<
我按照这个教程乖乖的做了...可是为什么最后一步「窗口闪避与隐藏」不成功??
角色走到窗口边都没闪避的效果,按键了也不隐藏-.-
作者: larbi    时间: 2009-5-15 03:42
  1. class Scene_Map
  2.   #--------------------------------------------------------------------------
  3.   # ● 主处理
  4.   #--------------------------------------------------------------------------
  5.   def main
  6.     # 生成活动块
  7.     @spriteset = Spriteset_Map.new
  8.     # 生成信息窗口
  9.     @message_window = Window_Message.new
  10.     @time_date_window = Window_Time_Date.new
  11.     @gold_window = Window_Gold.new
  12.     @gold_window.x = 75   
  13.     @gold_window.y = 20
  14.     # 执行过渡
  15.     Graphics.transition
  16.     # 主循环
  17.     loop do
  18.       # 刷新游戏画面
  19.       Graphics.update
  20.       # 刷新输入信息
  21.       Input.update
  22.       # 刷新画面
  23.       update
  24.       # 如果画面切换的话就中断循环
  25.       if $scene != self
  26.         break
  27.       end
  28.     end
  29.     # 准备过渡
  30.     Graphics.freeze
  31.     # 释放活动块
  32.     @spriteset.dispose
  33.     # 释放信息窗口
  34.     @message_window.dispose
  35.     @time_date_window.dispose
  36.     @gold_window.dispose
  37.     # 标题画面切换中的情况下
  38.     if $scene.is_a?(Scene_Title)
  39.       # 淡入淡出画面
  40.       Graphics.transition
  41.       Graphics.freeze
  42.     end
  43.   end

  44. alias timedate_update update
  45. def update
  46. timedate_update
  47. @gold_window.refresh

  48. end # end def update
  49. end

  50. #-----------------------------------------
  51. class Window_Time_Date < Window_Base
  52. #-----------------------------------------
  53. def initialize
  54. super(0, 0, 240, 80)
  55. self.contents = Bitmap.new(width - 32, height - 32)
  56.    $game_variables[3] = 30
  57.    $game_variables[4] = 12
  58.    $game_variables[5] = 1

  59. unless $scene.is_a?(Scene_Shop)
  60. end
  61. refresh
  62. end # end def initialize

  63. def refresh

  64. @total_sec = Graphics.frame_count
  65. if $game_variables[3] >= 30 + 1
  66.      $game_variables[3] = 1
  67.      $game_variables[4] += 1
  68.    end # end if $game_variables[3] >= 30 + 1
  69.    
  70.    if $game_variables[4] >= 12 + 1
  71.      $game_variables[4] = 1
  72.      $game_variables[5] += 1
  73.    end # end if $game_variables[4] >= 12 + 1

  74.   
  75. text_day = ["","1日","2日","3日","4日","5日","6日","7日","8日","9日","10日",
  76.             "11日","12日","13日","14日","15日","16日","17日","18日","19日","20日",
  77.             "21日","22日","23日","24日","25日","26日","27日","28日","29日","30日",][$game_variables[3]]
  78. text_month = ["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月",
  79.               "11月","12月",][$game_variables[4]]
  80. text_year = ["", "第1年","第2年","第3年","第4年"][$game_variables[5]]

  81. self.contents.clear
  82. self.contents.draw_text(0, -5, 128, 32, text_month)
  83. self.contents.draw_text(45, -5, 128, 32, text_day)
  84. self.contents.draw_text(15, -5, 128, 80,text_year)
  85.    
  86. self.contents.font.color = system_color
  87. self.contents.draw_text(100, -5, 128, 32, "名声") #描绘声望字样
  88. self.contents.font.color = normal_color
  89. self.contents.draw_text(170,-5,128, 32, $game_variables[1].to_s)#描绘声望值.

  90. if $game_player.screen_x >= (0 - 16) && $game_player.screen_x <= (0 + 640 + 16)
  91.      if $game_player.screen_y >= (0 - 16) && $game_player.screen_y <= (0 + 55 + 16)
  92.        self.x = 0
  93.        self.y = 425
  94.        @time_date_time_window_shifted = true
  95.      else
  96.        self.x = 0
  97.        self.y = 0
  98.        @time_date_time_window_shifted = false
  99.      end # end if $game_player.screen_y >= (0 - 16) && $game_player.screen_y <= (0 + 55 + 16)
  100.    else
  101.      self.x = 0
  102.      self.y = 0
  103.      @time_date_time_window_shifted = false
  104.    end # end if $game_player.screen_x >= (0 - 16) && $game_player.screen_x <= (0 + 640 + 16)
  105.    
  106.    if Input.press?(Input::A)
  107.      if @time_date_time_window_shifted == true
  108.        self.x = 0
  109.        self.y = 425
  110.      else
  111.        self.x = 0
  112.        self.y = 0
  113.      end # end if @time_date_time_window_shifted = true
  114.    else
  115.      if @time_date_time_window_shifted == true
  116.        self.y = 425 + 55 - 8
  117.      else
  118.        self.y = -(55) + 8
  119.      end # end if @time_date_time_window_shifted = true
  120.    end # end if Input.press?(Input::A)


  121. end # end def refresh

  122. def update

  123. end
  124. end
复制代码


这个是我按照教程做的...当然有些东西还是有点不一样,大大们可以54...= =|||

现在主要想解决如何做到"窗口隐藏与闪避"的问题>.<
---------------------------------------
囧 心急忘记编辑了...请不要扣分T-T [LINE]1,#dddddd[/LINE]版主对此帖的评论:『最后一句话是特意加的么?那我就连象征都不性了……』,积分『-0』。这些被扣积分的一半会用于对本帖正确答案的悬赏。
作者: 紫苏    时间: 2009-5-15 16:16
既然刷新是写在窗口的 refresh 中的,就应该在地图循环中随时调用这个方法:
alias timedate_update update
def update
   timedate_update
   @gold_window.refresh
   @time_date_window.refresh
end





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