Project1
标题: 求通过脚本来随时刷新变量显示的方法 [打印本页]
作者: 213blackcat 时间: 2021-2-4 20:14
标题: 求通过脚本来随时刷新变量显示的方法
如题,是脚本小白,学着做了个窗口显示游戏中的变量,但是不知道怎么刷新这个变量数值……(查了半天也不知道怎么弄)
求大神救救孩子!谢谢!
作者: 213blackcat 时间: 2021-2-4 20:15
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); //把窗口添加到窗口层
};
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); //把窗口添加到窗口层
};
作者: 213blackcat 时间: 2021-2-4 20:19
https://rpg.blue/forum.php?mod=viewthread&tid=400297是从这个文件中学的,所以本来是显示角色名称,很多变量名也是角色名称相关
作者: 213blackcat 时间: 2021-2-4 20:30
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();
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();
作者: 213blackcat 时间: 2021-2-4 20:33
最新的这个可以显示变量了!!!!!经过测试完全没问题(可以用来显示游戏时间)
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |