查看: 5618|回复: 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 | 显示全部楼层
[pre lang="javascript"]var $refresh = true;
function Window_MapStatus() {
    this.initialize.apply(this,arguments)
}
Window_MapStatus.prototype = Object.create(Window_Base.prototype);
Window_MapStatus.prototype.constructor = Window_MapStatus;
Window_MapStatus.prototype.initialize = function (x, y, width, height) {
    Window_Base.prototype.initialize.call(this, x, y, width, height);
    this.opacity = 0;
    this.refresh();
}

Window_MapStatus.prototype.refresh = function () {
    this.contents.clear();
    this.drawText($gameVariables.value(1), 0, 0, this.Width);
    this.drawText(":", 30, 0, this.Width);
    this.drawText($gameVariables.value(2), 60, 0, this.Width);
    this.drawText(":", 90, 0, this.Width);
    this.drawText($gameVariables.value(3), 120, 0, this.Width);
}

Scene_Map.prototype.createDisplayObjects = function () {
    //创建精灵组
    this.createSpriteset();
    //创建地图名称窗口
    this.createMapNameWindow();
    //创建窗口层
    this.createWindowLayer();
    //创建所有窗口
    this.createAllWindows();

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



};

//创建一个显示名字的窗口
Scene_Map.prototype.createStatusWindow = function () {
    this._StatusWindow = new Window_MapStatus(0,0,410,216);
    this._StatusWindow.refresh();
    this.addWindow(this._StatusWindow); //把窗口添加到窗口层
   
};
[/pre]
回复

使用道具 举报

梦石
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 | 显示全部楼层
[pre lang="javascript"]var $refresh = true;
function Window_MapStatus() {
    this.initialize.apply(this,arguments)
}
Window_MapStatus.prototype = Object.create(Window_Base.prototype);
Window_MapStatus.prototype.constructor = Window_MapStatus;
Window_MapStatus.prototype.initialize = function (x, y, width, height) {
    Window_Base.prototype.initialize.call(this, x, y, width, height);
    this.opacity = 0;
    this.refresh();
    $refresh = true;
}

Window_MapStatus.prototype.refresh = function () {
    this.contents.clear();
    this.drawText($gameVariables.value(1), 0, 0, this.Width);
    this.drawText(":", 30, 0, this.Width);
    this.drawText($gameVariables.value(2), 60, 0, this.Width);
    this.drawText(":", 90, 0, this.Width);
    this.drawText($gameVariables.value(3), 120, 0, this.Width);
}

Window_MapStatus.prototype.update = function () {
    Window_Base.prototype.update.call(this);
    if($refresh){
        this.refresh();
    }
    if ($gamePlayer.screenX() >= 0 && $gamePlayer.screenX() <= this.width && $gamePlayer.screenY() >= 0 && $gamePlayer.screenY() <= this.height)
    {
        this.contentsOpacity = 75;
    }
    else this.contentsOpacity = 225;
}
Scene_Map.prototype.createDisplayObjects = function () {
    //创建精灵组
    this.createSpriteset();
    //创建地图名称窗口
    this.createMapNameWindow();
    //创建窗口层
    this.createWindowLayer();
    //创建所有窗口
    this.createAllWindows();

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

评分

参与人数 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.

在本版发帖返回顶部