查看: 2307|回复: 4

[已经解决] 请问如何使画面窗口显示实时更新

[复制链接]
梦石
0
星屑
350
在线时间
35 小时
注册时间
2017-8-30
回帖
8
发表于 2018-2-15 17:19:05 | 显示全部楼层 |阅读模式

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

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

×
这样的话可以显示遇怪的剩余步数,但是只有打开并关闭菜单或者战斗后才能刷新数字。请问怎么能在地图上行走的情况下实时刷新数字
  1. #==============================================================================
  2. # ■ Window_Douzhi
  3. #------------------------------------------------------------------------------
  4. #  菜单画面显示剩余遇敌步数的窗口。
  5. #==============================================================================

  6. class Window_Yudi <  Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 0, 160, 96)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.   refresh
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # ● 刷新
  17.   #--------------------------------------------------------------------------
  18.   def refresh
  19.     self.contents.clear
  20.     self.contents.font.color = system_color
  21.     self.contents.draw_text(4, 0, 120, 32, "剩余步数:")
  22.     self.contents.font.color = normal_color
  23.     self.contents.draw_text(4, 32, 120, 32, $game_player.encounter_count.to_s, 2)
  24.   end
  25. end
复制代码
梦石
0
星屑
350
在线时间
35 小时
注册时间
2017-8-30
回帖
8
 楼主| 发表于 2018-2-16 20:13:10 | 显示全部楼层
已成功自己解决
在scene_map下使用了if做了些修改

点评

嗯...话说是怎么判断的呢?  发表于 2018-2-16 20:58
回复

使用道具 举报

梦石
1
星屑
24088
在线时间
3339 小时
注册时间
2011-7-8
回帖
3862

开拓者

发表于 2018-2-16 21:15:40 | 显示全部楼层
频繁绘制文字(draw_text)会导致帧率明显下降,要记得判断文字内容没有发生变化的情况下跳过绘制。
熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复

使用道具 举报

梦石
0
星屑
350
在线时间
35 小时
注册时间
2017-8-30
回帖
8
 楼主| 发表于 2018-2-17 11:05:16 | 显示全部楼层
先把98号变量等于遇敌剩余步数 $game_variables[98]=$game_player.encounter_count
然后把下面的$game_player.encounter_count.to_s更改为$game_variables[98]to_s #意义不明 貌似直接用会报错
然后把scene map里的刷新窗口的@窗口.update更改为
if $game_variables[98] != @record98 and $game_variables[98] != nil
    @record98 = $game_variables[98]
    @窗口.update
    end
另外可以添加开关开启或者关闭窗口
  1. #==============================================================================
  2. # ■ Window_Yudi
  3. #------------------------------------------------------------------------------
  4. #  菜单画面显示剩余遇敌步数的窗口。
  5. #==============================================================================

  6. class Window_Yudi <  Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 0, 160, 96)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.   update
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # ● 刷新
  17.   #--------------------------------------------------------------------------
  18.   def update
  19.     if $game_switches[505] == true
  20.     $game_variables[98]=$game_player.encounter_count
  21.     self.contents.clear
  22.     self.contents.font.color = system_color
  23.     self.contents.draw_text(4, 0, 120, 32, "遇敌步数:")
  24.     self.contents.font.color = normal_color
  25.     self.contents.draw_text(4, 32, 120, 32, $game_variables[98].to_s, 2)
  26.     self.opacity = 0
  27.     self.z=999999
  28.   else
  29.   self.opacity = 0
  30. end
  31. end
  32. end
复制代码

评分

参与人数 2星屑 +25 赞 +2 收起 理由
RyanBern + 25 + 1 赞自行解决问题
文雅夕露 + 1

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部