| 沙漠点灰 发表于 2013-8-24 02:33 ![]() 将一个实例变量赋为所写窗口的新实例,即可,所有Scene都继承Scene_Base,窗口类不必再写x.update,也不必 ...
按照你所说的写了脚本
 
 
 class Window_Mine < Window_Base   CHANGE_COUNT = 16 # 自己一般将特效设为16帧   def initialize(block=nil)     super(0, 0, Graphics.width, Graphics.height)     @counterr = 0     [url=home.php?mod=space&uid=272828]@BLock[/url] = block     @step = :in  end   def f(x) # 2次函数用于非平均渐变    (x-1)**2  end   def update    case @step    when :in # 入      self.opacity = self.contents_opacity = 255 - f(@counter.to_f/CHANGE_COUNT) * 255      return @step = :nor if @counter >= CHANGE_COUNT # 跳转步骤设为平    when :nor # 平       super # 正常刷新    when :out # 出      self.opacity = self.contents_opacity = f(@counter.to_f/CHANGE_COUNT) * 255      if @counter >= CHANGE_COUNT # 销毁步骤        @block.call if @block        return @step=nil      end    end    @counter += 1  end   def end!    @step = :out # 设置跳转步骤为 出  end end
class Window_Mine < Window_Base 
  
  CHANGE_COUNT = 16 # 自己一般将特效设为16帧 
  
  def initialize(block=nil) 
     super(0, 0, Graphics.width, Graphics.height) 
     @counterr = 0 
     [url=home.php?mod=space&uid=272828]@BLock[/url] = block 
     @step = :in 
  end 
  
  def f(x) # 2次函数用于非平均渐变 
    (x-1)**2 
  end 
  
  def update 
    case @step 
    when :in # 入 
      self.opacity = self.contents_opacity = 255 - f(@counter.to_f/CHANGE_COUNT) * 255 
      return @step = :nor if @counter >= CHANGE_COUNT # 跳转步骤设为平 
    when :nor # 平 
       super # 正常刷新 
    when :out # 出 
      self.opacity = self.contents_opacity = f(@counter.to_f/CHANGE_COUNT) * 255 
      if @counter >= CHANGE_COUNT # 销毁步骤 
        @block.call if @block 
        return @step=nil 
      end 
    end 
    @counter += 1 
  end 
  
  def end! 
    @step = :out # 设置跳转步骤为 出 
  end 
  
end 
 
 之后在游戏中的事件脚本里用
 
 @window_mine = Window_Mine.new
 
 显示了窗口
 
 但是,使用
 
 @window_mine.end!
 
 却无法消除窗口,请问是怎么回事?
 |