查看: 5721|回复: 4

[有事请教] 求通过脚本来随时刷新变量显示的方法

[复制链接]
梦石
0
星屑
262
在线时间
49 小时
注册时间
2019-1-12
回帖
37
发表于 2021-2-4 20:14:34 | 显示全部楼层 |阅读模式
悬赏30星屑未解决
如题,是脚本小白,学着做了个窗口显示游戏中的变量,但是不知道怎么刷新这个变量数值……(查了半天也不知道怎么弄)
求大神救救孩子!谢谢!

梦石
0
星屑
262
在线时间
49 小时
注册时间
2019-1-12
回帖
37
 楼主| 发表于 2021-2-4 20:15:27 | 显示全部楼层
  1. var $refresh = true;
  2. function Window_MapStatus() {
  3.     this.initialize.apply(this,arguments)
  4. }
  5. Window_MapStatus.prototype = Object.create(Window_Base.prototype);
  6. Window_MapStatus.prototype.constructor = Window_MapStatus;
  7. Window_MapStatus.prototype.initialize = function (x, y, width, height) {
  8.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  9.     this.opacity = 0;
  10.     this.refresh();
  11. }

  12. Window_MapStatus.prototype.refresh = function () {
  13.     this.contents.clear();
  14.     this.drawText($gameVariables.value(1), 0, 0, this.Width);
  15.     this.drawText(":", 30, 0, this.Width);
  16.     this.drawText($gameVariables.value(2), 60, 0, this.Width);
  17.     this.drawText(":", 90, 0, this.Width);
  18.     this.drawText($gameVariables.value(3), 120, 0, this.Width);
  19. }

  20. Scene_Map.prototype.createDisplayObjects = function () {
  21.     //创建精灵组
  22.     this.createSpriteset();
  23.     //创建地图名称窗口
  24.     this.createMapNameWindow();
  25.     //创建窗口层
  26.     this.createWindowLayer();
  27.     //创建所有窗口
  28.     this.createAllWindows();

  29.     //创建一个显示角色状态的窗口
  30.     this.createStatusWindow();



  31. };

  32. //创建一个显示名字的窗口
  33. Scene_Map.prototype.createStatusWindow = function () {
  34.     this._StatusWindow = new Window_MapStatus(0,0,410,216);
  35.     this._StatusWindow.refresh();
  36.     this.addWindow(this._StatusWindow); //把窗口添加到窗口层
  37.    
  38. };
复制代码
回复

使用道具 举报

梦石
0
星屑
262
在线时间
49 小时
注册时间
2019-1-12
回帖
37
 楼主| 发表于 2021-2-4 20:19:48 | 显示全部楼层
https://rpg.blue/forum.php?mod=viewthread&tid=400297是从这个文件中学的,所以本来是显示角色名称,很多变量名也是角色名称相关
回复

使用道具 举报

梦石
0
星屑
262
在线时间
49 小时
注册时间
2019-1-12
回帖
37
 楼主| 发表于 2021-2-4 20:30:37 | 显示全部楼层
  1. var $refresh = true;
  2. function Window_MapStatus() {
  3.     this.initialize.apply(this,arguments)
  4. }
  5. Window_MapStatus.prototype = Object.create(Window_Base.prototype);
  6. Window_MapStatus.prototype.constructor = Window_MapStatus;
  7. Window_MapStatus.prototype.initialize = function (x, y, width, height) {
  8.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  9.     this.opacity = 0;
  10.     this.refresh();
  11.     $refresh = true;
  12. }

  13. Window_MapStatus.prototype.refresh = function () {
  14.     this.contents.clear();
  15.     this.drawText($gameVariables.value(1), 0, 0, this.Width);
  16.     this.drawText(":", 30, 0, this.Width);
  17.     this.drawText($gameVariables.value(2), 60, 0, this.Width);
  18.     this.drawText(":", 90, 0, this.Width);
  19.     this.drawText($gameVariables.value(3), 120, 0, this.Width);
  20. }

  21. Window_MapStatus.prototype.update = function () {
  22.     Window_Base.prototype.update.call(this);
  23.     if($refresh){
  24.         this.refresh();
  25.     }
  26.     if ($gamePlayer.screenX() >= 0 && $gamePlayer.screenX() <= this.width && $gamePlayer.screenY() >= 0 && $gamePlayer.screenY() <= this.height)
  27.     {
  28.         this.contentsOpacity = 75;
  29.     }
  30.     else this.contentsOpacity = 225;
  31. }
  32. Scene_Map.prototype.createDisplayObjects = function () {
  33.     //创建精灵组
  34.     this.createSpriteset();
  35.     //创建地图名称窗口
  36.     this.createMapNameWindow();
  37.     //创建窗口层
  38.     this.createWindowLayer();
  39.     //创建所有窗口
  40.     this.createAllWindows();

  41.     //创建一个显示角色状态的窗口
  42.     this.createStatusWindow();
复制代码

评分

参与人数 1赞 +1 收起 理由
白嫩白嫩的 + 1 精品文章

查看全部评分

回复

使用道具 举报

梦石
0
星屑
262
在线时间
49 小时
注册时间
2019-1-12
回帖
37
 楼主| 发表于 2021-2-4 20:33:57 | 显示全部楼层
最新的这个可以显示变量了!!!!!经过测试完全没问题(可以用来显示游戏时间)
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部