Ajuda Script de Pausa MV

9 Respostas   310 Visualizações

0 Membros e 1 Visitante estão vendo este tópico.

yukito220

  • *
  • Posts: 5
  • Ouros: 0
Tópico criado em: 07/09/2016 às 14:31 - Última modificação por yukito220 em 29/09/2016 às 15:27

Olá, sou novo no forúm e no rpg maker (hehehe)

Eu preciso muito de um plugin que pausa o jogo em andamento, apertando determinada tecla e que despausa apertando a mesma tecla.

eu consegui criar um evento onde pressionando a tecla "x" o jogo entrava em pausa, porém para despausar o jogo era necessário apertar a tecla "y". o que não me adianta muito.

grato pela ajuda!

Ven

Resposta 1: 07/09/2016 às 14:42

O Masked fez um bem legal, vale a pena conferir.

Espero ter ajudado.  :XD:

yukito220

  • *
  • Posts: 5
  • Ouros: 0
Resposta 2: 07/09/2016 às 14:53

Valeu amigo, mas no caso seria pra o rpg maker mv, esqueci de especificar a engine no tópico, me desculpe.

TonyHart

  • *
  • Posts: 144
  • Ouros: 126
  • Born in 95 to die
Resposta 3: 07/09/2016 às 19:50

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 ajudar

Có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();
    };

})();
Born in 95 to die

yukito220

  • *
  • Posts: 5
  • Ouros: 0
Resposta 4: 15/09/2016 às 18:40

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 ajudar

Có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();
    };

})();


A primeiro momento, o pausa faria o jogo entrar em modo de espera, fazendo com que tanto os eventos, scripts, sons e tal como o tempo de jogo ficassem congelado e retornassem a partir do momento que o o botão fosse apertado novamente,


para ser mais claro em todos os jogos (ao menos que seja online) há a possibilidade de pausá-lo e retomar, saca?

eu quero fazer isso sem a necessidade de que o player chame o menu toda vez que necessite parar o jogo.

obrigado, e muito grato amigo!

TonyHart

  • *
  • Posts: 144
  • Ouros: 126
  • Born in 95 to die
Resposta 5: 15/09/2016 às 23:27

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.
Born in 95 to die

yukito220

  • *
  • Posts: 5
  • Ouros: 0
Resposta 6: 17/09/2016 às 16:23

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.

Amigo, fico muito grato!você realmente está ajudando muito o projeto!

TonyHart

  • *
  • Posts: 144
  • Ouros: 126
  • Born in 95 to die
Resposta 7: 17/09/2016 às 17:45

Ok, vou fazer um então que pause esses itens: "o pausa faria o jogo entrar em modo de espera, fazendo com que tanto os eventos, scripts, sons e tal como o tempo de jogo". Assim que terminar posto aqui
Born in 95 to die

TonyHart

  • *
  • Posts: 144
  • Ouros: 126
  • Born in 95 to die
Resposta 8: 18/09/2016 às 00:29

Coloquei em um tópico explicando certinho como usar. Dá uma olhada e verifica se está de acordo com o que você queria.

Tópico: http://centrorpg.com/index.php?topic=15675
Born in 95 to die

yukito220

  • *
  • Posts: 5
  • Ouros: 0
Resposta 9: 29/09/2016 às 15:27

Fantástico! muito obrigado Amigo, era exatamente o que precisava!