本帖最后由 everlose 于 2016-9-14 08:16 编辑
你的问题 我已经解决了
问题在于 推送 Scene_Base.prototype.XY_Toast_old_updateChildren = Scene_Base.prototype.updateChildren;
推送把原来的UPDATECHILDREN 重新封装
Scene_Base.prototype.XY_Toast_old_updateChildren = Scene_Base.prototype.updateChildren; //XY_Toast_key=false; Scene_Base.prototype.updateChildren = function() { this.XY_Toast_old_updateChildren(); //if(XY_Toast_key){ $gameTemp.updatetoast(); //}; };
Scene_Base.prototype.XY_Toast_old_updateChildren = Scene_Base.prototype.updateChildren;
//XY_Toast_key=false;
Scene_Base.prototype.updateChildren = function() {
this.XY_Toast_old_updateChildren();
//if(XY_Toast_key){
$gameTemp.updatetoast();
//};
};
注释是我修改的部分
因为他重新封装之后需要调用GAMETEMP.UPDATETOAST()这个函数
Game_Temp.prototype.XY_Toast_old_initialize = Game_Temp.prototype.initialize; Game_Temp.prototype.initialize = function() { this.XY_Toast_old_initialize(); this._toastlist = []; }; Game_Temp.prototype.toast = function(text, color) { XY_Toast_key=true; this.alltoastmove(); this._toastlist.push(new XY_Toast(text, color)); }; Game_Temp.prototype.alltoastmove = function() { for(var i = 0;i < this._toastlist.length;i++){ this._toastlist[i].up(); } }; Game_Temp.prototype.updatetoast = function() { for(var i = 0;i < this._toastlist.length;i++){ this._toastlist[i].update(); if(this._toastlist[i].finish()){ this._toastlist.splice(i,1); i--; } } };
Game_Temp.prototype.XY_Toast_old_initialize = Game_Temp.prototype.initialize;
Game_Temp.prototype.initialize = function() {
this.XY_Toast_old_initialize();
this._toastlist = [];
};
Game_Temp.prototype.toast = function(text, color) {
XY_Toast_key=true;
this.alltoastmove();
this._toastlist.push(new XY_Toast(text, color));
};
Game_Temp.prototype.alltoastmove = function() {
for(var i = 0;i < this._toastlist.length;i++){
this._toastlist[i].up();
}
};
Game_Temp.prototype.updatetoast = function() {
for(var i = 0;i < this._toastlist.length;i++){
this._toastlist[i].update();
if(this._toastlist[i].finish()){
this._toastlist.splice(i,1);
i--;
}
}
};
而小优又重新封装了GAME_TEMP 即是$gametemp
而实际上当MOG的标题画面出现的时候调用了Scene_Base.prototype.updateChildren() 这时候小优封装 的gametemp还没初始化 所以报错
如我刚才给出的代码去掉注释.
Scene_Base.prototype.XY_Toast_old_updateChildren = Scene_Base.prototype.updateChildren; XY_Toast_key=false; Scene_Base.prototype.updateChildren = function() { this.XY_Toast_old_updateChildren(); if(XY_Toast_key){ $gameTemp.updatetoast();
Scene_Base.prototype.XY_Toast_old_updateChildren = Scene_Base.prototype.updateChildren;
XY_Toast_key=false;
Scene_Base.prototype.updateChildren = function() {
this.XY_Toast_old_updateChildren();
if(XY_Toast_key){
$gameTemp.updatetoast();
并在调用TOAST的时候加一个开关判断即可
Game_Temp.prototype.toast = function(text, color) { XY_Toast_key=true; this.alltoastmove(); this._toastlist.push(new XY_Toast(text, color)); };
Game_Temp.prototype.toast = function(text, color) {
XY_Toast_key=true;
this.alltoastmove();
this._toastlist.push(new XY_Toast(text, color));
};
小优任务系统也是原理如此
说白了就是初始化的问题 |