实时更新的时间系统
作为一个js的小白,今天在瓢虫和当当的帮助下写了这个插件,算是学习js的第一步吧!写好了拿出来跟大家分享一下,看有没有同样需要使用的小伙伴,也希望有大神多指导指导我!
脚本一开始是参照 @余烬之中 的教学贴写的窗口,后来在瓢虫和当当的帮助下,添加了变量调用和实时更新,在这里再次万分感谢!
顺便勾搭一下,有没有志同道合想一起做游戏的小伙伴?QQ330572745!
使用效果图:
https://rpg.blue/data/attachment/forum/201606/02/230852r8picir8f5fcfoio.png
脚本:
JAVASCRIPT 代码
Scene_Map.prototype.start = function(){
Scene_MenuBase.prototype.start.call(this);
SceneManager.clearStack();
if(this._transfer){
this.fadeInForTransfer();
this._mapNameWindow.open();
this._ningjingWindow.open();
$gameMap.autoplay();
}elseif(this.needsFadeIn()){
this.startFadeIn(this.fadeSpeed(), false);
}
this.menuCalling = false;
};
Scene_Map.prototype.stop = function(){
Scene_MenuBase.prototype.stop.call(this);
$gamePlayer.straighten();
this._mapNameWindow.close();
this._ningjingWindow.close();
if(this.needsSlowFadeOut()){
this.startFadeOut(this.slowFadeSpeed(), false);
}elseif(SceneManager.isNextScene(Scene_Map)){
this.fadeOutForTransfer();
}elseif(SceneManager.isNextScene(Scene_Battle)){
this.launchBattle();
}
};
Scene_Map.prototype.terminate = function(){
Scene_MenuBase.prototype.terminate.call(this);
if(!SceneManager.isNextScene(Scene_Battle)){
this._spriteset.update();
this._mapNameWindow.hide();
this._ningjingWindow.hide();
SceneManager.snapForBackground();
}
$gameScreen.clearZoom();
};
Scene_Map.prototype.createDisplayObjects = function(){
this.createSpriteset();
this.createMapNameWindow();
this.createNingJingWindow();
this.createWindowLayer();
this.createAllWindows();
};
Scene_Map.prototype.createNingJingWindow = function(){
this._ningjingWindow = new Window_Testing(550,580,260,40);
this.addChild(this._ningjingWindow);
};
Scene_Map.prototype.callMenu = function(){
SoundManager.playOk();
SceneManager.push(Scene_Menu);
Window_MenuCommand.initCommandPosition();
$gameTemp.clearDestination();
this._ningjingWindow.hide();
this._mapNameWindow.hide();
this._waitCount = 2;
};
Scene_Map.prototype.launchBattle = function(){
BattleManager.saveBgmAndBgs();
this.stopAudioOnBattleStart();
SoundManager.playBattleStart();
this.startEncounterEffect();
this._ningjingWindow.hide();
this._mapNameWindow.hide();
};
function Window_Testing(){
this.initialize.apply(this, arguments);
}
Window_Testing.prototype = Object.create(Window_Base.prototype);
Window_Testing.prototype.initialize = function(x, y, width, height){
Window_Base.prototype.initialize.call(this, x, y, width, height);
this.contents.fontSize = 20;
}
Window_Testing.prototype.standardPadding = function(){
return8;
};
Window_Testing.prototype.update = function(){
Window_Base.prototype.update.call(this);
if($gameVariables.value(1)==0){
$gameVariables._data=1
$gameVariables._data=1
$gameVariables._data=1
$gameVariables._data=1
}elseif($gameVariables.value(5)>=4){
$gameVariables._data-=4
$gameVariables._data+=1
}elseif($gameVariables.value(4)>=25){
$gameVariables._data-=24
$gameVariables._data+=1
}elseif($gameVariables.value(3)>=31){
$gameVariables._data-=30
$gameVariables._data+=1
}elseif($gameVariables.value(2)>=13){
$gameVariables._data-=12
$gameVariables._data+=1
}
var textW = 270;
var textH = 0;
this.contents.clear();
this.drawText($gameVariables.value(1) + "年", -180, -6, textW, 'right');
textH += this.lineHeight();
this.drawText($gameVariables.value(2) + "月", -130, -6, textW, 'right');
textH += this.lineHeight();
this.drawText($gameVariables.value(3) + "日", -80, -6, textW, 'right');
textH += this.lineHeight();
this.drawText($gameVariables.value(4) + "时", -30, -6, textW, 'right');
textH += this.lineHeight();
};
本帖来自P1论坛作者宁静,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=393843若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页:
[1]