设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 4857|回复: 4
打印 上一主题 下一主题

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
262
在线时间
49 小时
注册时间
2019-1-12
帖子
48
跳转到指定楼层
1
发表于 2021-2-4 20:14:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
30星屑
如题,是脚本小白,学着做了个窗口显示游戏中的变量,但是不知道怎么刷新这个变量数值……(查了半天也不知道怎么弄)
求大神救救孩子!谢谢!

Lv2.观梦者

梦石
0
星屑
262
在线时间
49 小时
注册时间
2019-1-12
帖子
48
2
 楼主| 发表于 2021-2-4 20:15:27 | 只看该作者
JAVASCRIPT 代码复制
  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.  
  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.  
  22. Scene_Map.prototype.createDisplayObjects = function () {
  23.     //创建精灵组
  24.     this.createSpriteset();
  25.     //创建地图名称窗口
  26.     this.createMapNameWindow();
  27.     //创建窗口层
  28.     this.createWindowLayer();
  29.     //创建所有窗口
  30.     this.createAllWindows();
  31.  
  32.     //创建一个显示角色状态的窗口
  33.     this.createStatusWindow();
  34.  
  35.  
  36.  
  37. };
  38.  
  39. //创建一个显示名字的窗口
  40. Scene_Map.prototype.createStatusWindow = function () {
  41.     this._StatusWindow = new Window_MapStatus(0,0,410,216);
  42.     this._StatusWindow.refresh();
  43.     this.addWindow(this._StatusWindow); //把窗口添加到窗口层
  44.  
  45. };
回复

使用道具 举报

Lv2.观梦者

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

使用道具 举报

Lv2.观梦者

梦石
0
星屑
262
在线时间
49 小时
注册时间
2019-1-12
帖子
48
4
 楼主| 发表于 2021-2-4 20:30:37 | 只看该作者
JAVASCRIPT 代码复制
  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.  
  14. Window_MapStatus.prototype.refresh = function () {
  15.     this.contents.clear();
  16.     this.drawText($gameVariables.value(1), 0, 0, this.Width);
  17.     this.drawText(":", 30, 0, this.Width);
  18.     this.drawText($gameVariables.value(2), 60, 0, this.Width);
  19.     this.drawText(":", 90, 0, this.Width);
  20.     this.drawText($gameVariables.value(3), 120, 0, this.Width);
  21. }
  22.  
  23. Window_MapStatus.prototype.update = function () {
  24.     Window_Base.prototype.update.call(this);
  25.     if($refresh){
  26.         this.refresh();
  27.     }
  28.     if ($gamePlayer.screenX() >= 0 && $gamePlayer.screenX() <= this.width && $gamePlayer.screenY() >= 0 && $gamePlayer.screenY() <= this.height)
  29.     {
  30.         this.contentsOpacity = 75;
  31.     }
  32.     else this.contentsOpacity = 225;
  33. }
  34. Scene_Map.prototype.createDisplayObjects = function () {
  35.     //创建精灵组
  36.     this.createSpriteset();
  37.     //创建地图名称窗口
  38.     this.createMapNameWindow();
  39.     //创建窗口层
  40.     this.createWindowLayer();
  41.     //创建所有窗口
  42.     this.createAllWindows();
  43.  
  44.     //创建一个显示角色状态的窗口
  45.     this.createStatusWindow();

评分

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

查看全部评分

回复

使用道具 举报

Lv2.观梦者

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

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-15 07:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表