Project1

标题: 为了一个窗口更新我快疯了,求助…… [打印本页]

作者: ML4455739    时间: 2010-12-26 00:58
标题: 为了一个窗口更新我快疯了,求助……
本帖最后由 ML4455739 于 2010-12-26 01:03 编辑

RT,我弄了个窗口:
  1. class WW_Window < Window_Base
  2. def initialize
  3.    super(180, 0, 460, 480) # 定义窗口的显示位置和高、宽
  4.    self.contents = Bitmap.new(width-32, height-32)  
  5.    self.contents.font.name = "黑体"  
  6.    refresh
  7. end

  8. def refresh
  9.    if $w == 1
  10.    text = "文字1"
  11.    self.contents.font.color = Color.new(255, 0, 0, 255) #Red
  12.    self.contents.draw_text(4, 0, 406, 32, text)
  13.    end
  14.    if $w == 2
  15.    text = "文字2"
  16.    self.contents.font.color = Color.new(255, 0, 0, 255) #Red
  17.    self.contents.draw_text(4, 0, 406, 32, text)
  18.    end
  19. end
  20. end

  21. def update
  22.    $WW_window.updata
  23.    Graphics.update
  24.    if Graphics.frame_count / Graphics.frame_rate != @total_sec
  25.      refresh
  26.    end
  27. end
复制代码
当要显示文字2的时候,怎么才能让文字1不留在上面?
作者: enghao_lim    时间: 2010-12-26 03:43
def refresh
   self.contents.clear
   if $w == 1
   text = "文字1"
   self.contents.font.color = Color.new(255, 0, 0, 255) #Red
   self.contents.draw_text(4, 0, 406, 32, text)
   end
   if $w == 2
   text = "文字2"
   self.contents.font.color = Color.new(255, 0, 0, 255) #Red
   self.contents.draw_text(4, 0, 406, 32, text)
   end
end
end

筹字…………
作者: ML4455739    时间: 2010-12-26 12:34
表示没报错但也没效果,真的,和没加一样,字还是在上面
作者: enghao_lim    时间: 2010-12-26 12:44
本帖最后由 enghao_lim 于 2010-12-26 12:46 编辑

回复 ML4455739 的帖子

我是想说……那绝对有效果。如果字还出现就代表那个文字又再度被描绘……那是你写的脚本可能那边出问题了。
尝试用这样的书写方式:
  1. def refresh
  2.    self.contents.clear
  3.    if $w == 1
  4.      text = "文字1"
  5.      self.contents.font.color = Color.new(255, 0, 0, 255) #Red
  6.      self.contents.draw_text(4, 0, 406, 32, text)
  7.    else
  8.      text = "文字2"
  9.      self.contents.font.color = Color.new(255, 0, 0, 255) #Red
  10.      self.contents.draw_text(4, 0, 406, 32, text)
  11.    end
  12. end
  13. end
复制代码

作者: Wind2010    时间: 2010-12-26 12:44
$WW_window.updata
这句需要改成$WW_window.refresh ?
作者: IamI    时间: 2010-12-26 15:02
先把
   $WW_window.updata
   Graphics.update
这两行诡异玩意儿干掉或者修正,Graphics.update会导致实际刷新速率减慢1倍。
此后,请修改
  1. def refresh
  2.     self.contents.clear
  3.     p ""
  4.    if $w == 1
  5.    text = "文字1"
  6.    self.contents.font.color = Color.new(255, 0, 0, 255) #Red
  7.    self.contents.draw_text(4, 0, 406, 32, text)
  8.    end
  9.    if $w == 2
  10.    text = "文字2"
  11.    self.contents.font.color = Color.new(255, 0, 0, 255) #Red
  12.    self.contents.draw_text(4, 0, 406, 32, text)
  13.    end
  14. end
复制代码
然后运行检查能否看到一个空框,如果不能,refresh没有被运行,请检查触发条件。




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