红狼游戏中心

标题: MV实时更新的时间插件 [打印本页]

作者: unclequiet    时间: 2016-6-2 21:32
标题: MV实时更新的时间插件
今天在当当和瓢虫的帮助下写了这个插件,算是学习js的第一步吧!写好了拿出来跟大家分享一下,看有没有同样需要使用的小伙伴!

使用效果:
[attach]315[/attach]

代码:
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();
    } else if (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);
    } else if (SceneManager.isNextScene(Scene_Map)) {
        this.fadeOutForTransfer();
    } else if (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() {
    return 8;
};

Window_Testing.prototype.update = function() {
    Window_Base.prototype.update.call(this);
    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();
};


使用了一个公共时间和一个场景时间来操作时间进位
[attach]316[/attach]
[attach]317[/attach]

或许可以把这两个也并入到插件里去?
再次感谢当当和瓢虫!

作者: unclequiet    时间: 2016-6-2 23:06
在瓢虫和当当的帮助下,又把这个插件改进了
现在已经不需要在游戏中添加时间来操作时间进位和开启
全部都并入到脚本中去啦!

脚本:
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();
    } else if (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);
    } else if (SceneManager.isNextScene(Scene_Map)) {
        this.fadeOutForTransfer();
    } else if (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() {
    return 8;
};

Window_Testing.prototype.update = function() {
    Window_Base.prototype.update.call(this);
               
        if ($gameVariables.value(1)==0){
                $gameVariables._data[1]=1
                $gameVariables._data[2]=1
                $gameVariables._data[3]=1
                $gameVariables._data[4]=1
        }else if($gameVariables.value(5)>=4){
                $gameVariables._data[5]-=4
                $gameVariables._data[4]+=1
        }else if($gameVariables.value(4)>=25){
                $gameVariables._data[4]-=24
                $gameVariables._data[3]+=1
        }else if($gameVariables.value(3)>=31){
                $gameVariables._data[3]-=30
                $gameVariables._data[2]+=1
        }else if($gameVariables.value(2)>=13){
                $gameVariables._data[2]-=12
                $gameVariables._data[1]+=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();
};
作者: kds    时间: 2016-6-6 17:53
请上传一下文件,后面会改版网站,加入插件演示和下载的模块
作者: unclequiet    时间: 2016-8-11 11:45
kds 发表于 2016-6-6 17:53
请上传一下文件,后面会改版网站,加入插件演示和下载的模块

好的,最近一直没上来呢……
作者: dongdiyu78    时间: 2018-7-24 01:15
感谢楼主,这边受益匪浅




欢迎光临 红狼游戏中心 (http://www.kdsrpg.com/) Powered by Discuz! X3.2