Confira o Videos Épicos #45!
9 Respostas   310 Visualizações
0 Membros e 1 Visitante estão vendo este tópico.
//=============================================================================// Spring_Pause.js//=============================================================================/*: * @plugindesc Pausar jogo com tecla. Para lista de código acessar http://keycode.info/ * @author Tony Hart * * @param teclaKey * @desc Char Code Tecla: Default 'P' = 80 * @default 80 * * @param mostrarJanela * @desc Mostrar Janela de Pause * @default 1 * * @help This plugin does not provide plugin commands. */(function() { var parameters = PluginManager.parameters('Spring_Pause'); var teclaKey = isNaN(Number(parameters['teclaKey'])) ? 80 : Number(parameters['teclaKey']); var mostrarJanela = Number(parameters['mostrarJanela']) != 0; var gamePaused = false; var pauseWindow = null; Input.keyMapper[teclaKey] = 'pause'; Input.gamepadMapper[16] = 'pause'; var _Input_update = Input.update; Input.update = function() { for (var name in this._currentState) { if (this._currentState[name] && !this._previousState[name]) { gamePaused = !gamePaused; if(gamePaused) { pauseWindow.open(); } else { pauseWindow.close(); } } } _Input_update.call(this); }; var _Game_Event_updateMove = Game_Event.prototype.updateMove; Game_Event.prototype.updateMove = function() { if (gamePaused) return; _Game_Event_updateMove.call(this); }; //----------------------------------------------------------------------------- // Window_Pause // // The window for displaying the map name on the map screen. function Window_Pause() { this.initialize.apply(this, arguments); } Window_Pause.prototype = Object.create(Window_Base.prototype); Window_Pause.prototype.constructor = Window_Pause; Window_Pause.prototype.initialize = function() { var wight = this.windowWidth(); var height = this.windowHeight(); Window_Base.prototype.initialize.call(this, 0, 0, wight, height); this.opacity = 0; this.contentsOpacity = 0; this._showCount = 0; this.valueText = null; this.refresh(); }; Window_Pause.prototype.windowWidth = function() { return 360; }; Window_Pause.prototype.windowHeight = function() { return this.fittingHeight(1); }; Window_Pause.prototype.update = function() { Window_Base.prototype.update.call(this); if (gamePaused) { this.updateFadeIn(); this._showCount--; } else { this.updateFadeOut(); } }; Window_Pause.prototype.updateFadeIn = function() { this.contentsOpacity += 16; }; Window_Pause.prototype.updateFadeOut = function() { this.contentsOpacity -= 16; }; Window_Pause.prototype.open = function() { this.refresh(); this._showCount = 150; }; Window_Pause.prototype.close = function() { this._showCount = 0; }; Window_Pause.prototype.refresh = function() { var $value = (Graphics.frameCount % 64 > 20) ? 'PAUSADO' : ''; if(this.valueText !== $value) { this.contents.clear(); var width = this.contentsWidth(); this.drawBackground(0, 0, width, this.lineHeight()); this.drawText($value, 0, 0, width, 'center'); } }; Window_Pause.prototype.drawBackground = function(x, y, width, height) { var color1 = this.dimColor1(); var color2 = this.dimColor2(); this.contents.gradientFillRect(x, y, width / 2, height, color2, color1); this.contents.gradientFillRect(x + width / 2, y, width / 2, height, color1, color2); }; var _Scene_Map_createDisplayObjects = Scene_Map.prototype.createDisplayObjects; Scene_Map.prototype.createDisplayObjects = function() { _Scene_Map_createDisplayObjects.call(this); pauseWindow = new Window_Pause(); this.addChild(pauseWindow); }; var _Scene_Map_update = Scene_Map.prototype.update; Scene_Map.prototype.update = function() { _Scene_Map_update.call(this); pauseWindow.refresh(); };})();
Então cara, apenas falar pausar o jogo é meio genérico... Você teria que dizer o que prentede pausar.Segue abaixo um código que pausa os eventos que estão se movendo quando você aperta a tecla P por exemplo e mostra uma janela de pausa. Detalha um pouco mais o que realmente precisa ser pausado, aí eu vejo se posso te ajudarCódigo: [Selecionar]//=============================================================================// Spring_Pause.js//=============================================================================/*: * @plugindesc Pausar jogo com tecla. Para lista de código acessar http://keycode.info/ * @author Tony Hart * * @param teclaKey * @desc Char Code Tecla: Default 'P' = 80 * @default 80 * * @param mostrarJanela * @desc Mostrar Janela de Pause * @default 1 * * @help This plugin does not provide plugin commands. */(function() { var parameters = PluginManager.parameters('Spring_Pause'); var teclaKey = isNaN(Number(parameters['teclaKey'])) ? 80 : Number(parameters['teclaKey']); var mostrarJanela = Number(parameters['mostrarJanela']) != 0; var gamePaused = false; var pauseWindow = null; Input.keyMapper[teclaKey] = 'pause'; Input.gamepadMapper[16] = 'pause'; var _Input_update = Input.update; Input.update = function() { for (var name in this._currentState) { if (this._currentState[name] && !this._previousState[name]) { gamePaused = !gamePaused; if(gamePaused) { pauseWindow.open(); } else { pauseWindow.close(); } } } _Input_update.call(this); }; var _Game_Event_updateMove = Game_Event.prototype.updateMove; Game_Event.prototype.updateMove = function() { if (gamePaused) return; _Game_Event_updateMove.call(this); }; //----------------------------------------------------------------------------- // Window_Pause // // The window for displaying the map name on the map screen. function Window_Pause() { this.initialize.apply(this, arguments); } Window_Pause.prototype = Object.create(Window_Base.prototype); Window_Pause.prototype.constructor = Window_Pause; Window_Pause.prototype.initialize = function() { var wight = this.windowWidth(); var height = this.windowHeight(); Window_Base.prototype.initialize.call(this, 0, 0, wight, height); this.opacity = 0; this.contentsOpacity = 0; this._showCount = 0; this.valueText = null; this.refresh(); }; Window_Pause.prototype.windowWidth = function() { return 360; }; Window_Pause.prototype.windowHeight = function() { return this.fittingHeight(1); }; Window_Pause.prototype.update = function() { Window_Base.prototype.update.call(this); if (gamePaused) { this.updateFadeIn(); this._showCount--; } else { this.updateFadeOut(); } }; Window_Pause.prototype.updateFadeIn = function() { this.contentsOpacity += 16; }; Window_Pause.prototype.updateFadeOut = function() { this.contentsOpacity -= 16; }; Window_Pause.prototype.open = function() { this.refresh(); this._showCount = 150; }; Window_Pause.prototype.close = function() { this._showCount = 0; }; Window_Pause.prototype.refresh = function() { var $value = (Graphics.frameCount % 64 > 20) ? 'PAUSADO' : ''; if(this.valueText !== $value) { this.contents.clear(); var width = this.contentsWidth(); this.drawBackground(0, 0, width, this.lineHeight()); this.drawText($value, 0, 0, width, 'center'); } }; Window_Pause.prototype.drawBackground = function(x, y, width, height) { var color1 = this.dimColor1(); var color2 = this.dimColor2(); this.contents.gradientFillRect(x, y, width / 2, height, color2, color1); this.contents.gradientFillRect(x + width / 2, y, width / 2, height, color1, color2); }; var _Scene_Map_createDisplayObjects = Scene_Map.prototype.createDisplayObjects; Scene_Map.prototype.createDisplayObjects = function() { _Scene_Map_createDisplayObjects.call(this); pauseWindow = new Window_Pause(); this.addChild(pauseWindow); }; var _Scene_Map_update = Scene_Map.prototype.update; Scene_Map.prototype.update = function() { _Scene_Map_update.call(this); pauseWindow.refresh(); };})();
Entendi, bom o código que te passei foi só um exemplo... Não tinha como eu ficar programando sem saber exatemente o que voce queria. Mas se tiver interessado, posso ir fazendo, e você vai vendo se está de acordo.Qualquer coisa só responder aqui.