질문과 답변

Extra Form
종류 에러 해결

캡처_2022_03_27_23_24_29_489.png

화면이 약간 왼쪽으로 치우쳐져 있습니다

 

 

 

 

//=============================================================================
// MBS - Map Zoom (v1.3.5)
//-----------------------------------------------------------------------------
// por Masked
//=============================================================================
//-----------------------------------------------------------------------------
// Especificações do plugin (Não Modifique!)
// Plugin Specifications (Do not modify!)
//
/*:
 *
 * @author Masked
 * @plugindesc Makes it possible to zoom in and out the game map                        
 * 
 * <MBS MapZoom>
 * @help
 * ===========================================================================
 * Introduction
 * ===========================================================================
 * This script lets you change the game zoom as you want while in the map 
 * scene.
 *
 * ===========================================================================
 * How to use
 * ===========================================================================
 * You can set the map zoom with this plugin command:
 * 
 * MapZoom set x [y [duration n]]
 * 
 * Just change 'x' and 'y' to the zoom ratio you want (you can use floats).
 * Note that the "y" parameter is optional, if you don't use it then the 
 * script will assume it's equal to "x". If you want to define the zoom 
 * duration you can add a third parameter 'duration' followed by the number 
 * of frames the zoom operation will last. You can also add 'duration' as the
 * second parameter so that the 'y' zoom will be equal to the 'x'. If no
 * duration is set, it will be assumed it's 60 frames.
 * E.g.:
 * MapZoom set 2.0 duration 120
 * MapZoom set 2.0 1.5 duration 20
 *
 * If you want the zoom to be centralized on a specific X, Y coordinate or an
 * event, use this command:
 * MapZoom center x y
 * MapZoom center event id
 *
 * Just replace the 'x' and 'y' or 'id' for the values you want. E.g.:
 * MapZoom center 5 7
 * MapZoom center event 3
 *
 * To center on the player, use reset:
 * MapZoom center reset
 *
 * You can also use this to reset the zoom (set it to 1.0):
 * MapZoom reset [d]
 *
 * This will also reset the zoom center position.
 * If you want, you can choose the reset duration just changing 'd' for the 
 * number of frames you want it to take.
 * E.g.:
 * MapZoom reset 30
 *
 * If you want some picture to zoom along with the map, add "[Zoom]" to its 
 * name.
 * E.g.:
 * "img/pictures/SamplePicture1 [Zoom].png"
 *
 * ===========================================================================
 * Credits
 * ===========================================================================
 * - Masked, for creating.
 *
 * @param Reset on map change 
 * @desc If you want the zoom to be reset when the map changes, set this 
 * parameter to true. Set it to false otherwise.
 * @default true
 *
 * @param Default zoom
 * @desc The default zoom ratio, change this to apply a zoom to all of the game
 * maps.
 * @default 1.0
 *
 */
/*:pt
 *
 * @author Masked
 * @plugindesc Torna possível que você dê zoom no mapa durante o jogo.
 * 
 * <MBS MapZoom>
 * @help
 * ===========================================================================
 * Introdução
 * ===========================================================================
 * Esse script permite que você aumente ou diminua o zoom do jogo quando na 
 * cena do mapa.
 *
 * ===========================================================================
 * Utilização
 * ===========================================================================
 * Para definir o zoom do mapa use o seguinte comando:
 * 
 * MapZoom set x [y [duration d]]
 * 
 * Troque o X e Y pelos valores de zoom que quiser. Você pode usar decimais.
 * Note que o "y" é opcional, e se não for definido o script assumirá que seu 
 * valor é igual a X. Se você quiser, adicione um parâmetro 'duration' seguido
 * pelo número de frames que a operação deve levar, se a duração não for 
 * especificada ela será 60.
 * 
 * Exemplos:
 * MapZoom set 2.0 duration 120
 * MapZoom set 2.0 1.5 duration 20
 *
 * Se você quiser, pode centralizar a câmera do zoom em um evento ou 
 * coordenada usando esse comando:
 *
 * MapZoom center x y
 * MapZoom center event id
 *
 * Só troque o 'x' e 'y' ou 'id' pelos valores que quiser.
 * Exemplos:
 * MapZoom center 5 7
 * MapZoom center event 3
 *
 * Para centralizar no jogador, use o reset:
 * MapZoom center reset
 *
 * Você pode ainda resetar o zoom (mudar para 1.0):
 *
 * MapZoom reset [d]
 *
 * Se quiser, troque o '[d]' pelo número de frames que quiser que a operação
 * dure.
 *
 * Exemplos:
 * MapZoom reset 30
 * MapZoom reset
 *
 * Se quiser que uma picture seja afetada pelo zoom do mapa, adicione [Zoom] 
 * ao nome dela.
 * Exemplo:
 * "img/pictures/Imagem1 [Zoom].png"
 *
 * ===========================================================================
 * Créditos
 * ===========================================================================
 * - Masked, por criar.
 *
 * @param Reset on map change
 * @desc Caso queira que o zoom seja resetado quando o mapa mudar, deixe 
 * como true. Se não, deixe como false.
 * @default true
 *
 * @param Default zoom
 * @desc Valor padrão para o zoom da tela. Mude isso para aplicar um zoom a 
 * todos os mapas do jogo.
 * @default 1.0
 *
 */

var Imported = Imported || {};

var MBS = MBS || {};
MBS.MapZoom = {};

"use strict";

(function ($) {

  $.Parameters = $plugins.filter(function(p) {return p.description.contains('<MBS MapZoom>');})[0].parameters;
  $.Param = $.Param || {};

  //-----------------------------------------------------------------------------
  // Settings
  //

  // Flag to enable/disable resetting the zoom on map change
  $.Param.resetOnMapChange = ($.Parameters["Reset on map change"].toLowerCase() === "true");

  // Default zoom ratio
  $.Param.defaultZoom = Number($.Parameters["Default zoom"]);

  //-----------------------------------------------------------------------------
  // Game_Map
  //
  // The game map object. Here the main changes for controlling the map zoom were
  // made.

  // Aliases
  var _GameMap_initialize = Game_Map.prototype.initialize;
  var _GameMap_setup = Game_Map.prototype.setup;
  var _GameMap_update = Game_Map.prototype.update;

  // Object initialization. Here the zoom-related variables are created.
  Game_Map.prototype.initialize = function() {
    _GameMap_initialize.call(this);
    this._destZoom = this._destZoom || new PIXI.Point(0, 0);
    this._zoomTime = 0;
    this._zoomDuration = this._zoomDuration || 0;
    this._zoom = this._zoom || new PIXI.Point($.Param.defaultZoom, $.Param.defaultZoom);
    this._zoomCenter = null;
  };

  // Map setup. This will reset the map zoom if 'Reset on map change' is true.
  Game_Map.prototype.setup = function(mapId) {
    _GameMap_setup.call(this, mapId);
    if ($.Param.resetOnMapChange)
        this._zoom = new PIXI.Point($.Param.defaultZoom, $.Param.defaultZoom);
  };

  // Map update. This method controls the gradual zoom when a duration 
  // is specified.
  Game_Map.prototype.update = function () {
      _GameMap_update.apply(this, arguments);
      if (this._zoomDuration > this._zoomTime) {
        this.zoom.x += this._spdZoom.x;
        this.zoom.y += this._spdZoom.y;
        this._zoomTime++;
        this.onZoomChange();
    } else if (this._zoomTime > 0) {
        this._zoomTime = 0;
        this._zoomDuration = 0;
        this._spdZoom = new Point(0, 0);
    }
  };

  /**
   * Sets the game map zoom ratio.
   * @param {Number} x The horizontal zoom ratio
   * @param {Number} y The vertical zoom ratio
   */
  Game_Map.prototype.setZoom = function(x, y, duration) {
      duration = duration || 60;
      duration = Math.round(duration <= 0 ? 1 : duration) * 1.0;
      this._destZoom.x = this._destZoom.y = x;
      if (y) {
          this._destZoom.y = y;
      }
      this._spdZoom = new PIXI.Point((this._destZoom.x - this._zoom.x) / duration, (this._destZoom.y - this._zoom.y) / duration);
      this._zoomDuration = duration;
    this._zoomTime = 0;
  };

  /**
   * Sets the game map zoom origin.
   * @param {mixed} a Either a X coordinate or a Game_Character to center the zoom.
   * @param {Number} (Optional) A Y coordinate to center the zoom.
   */
  Game_Map.prototype.setZoomCenter = function(a, b) {
      if (b) {
          this._zoomCenter = new PIXI.Point(a, b);
      } else if (a) {
          this._zoomCenter = a;
      } else {
          this._zoomCenter = null;
      }
  };

  /**
   * Function called when the map zoom changes.
   */
  Game_Map.prototype.onZoomChange = function() {
    $gamePlayer.center((this._zoomCenter || $gamePlayer)._realX, (this._zoomCenter || $gamePlayer)._realY);
  };

  /**
   * Gets a map coordinate from a screen coordinate.
   * @param {Number} x The screen coordinate
   * @return The X position of the tile below the screen X given.
   */
  Game_Map.prototype.canvasToMapX = function(x) {
    var tileWidth = this.tileWidth() * this.zoom.x;
    var originX = this.displayX() * tileWidth;
    var mapX = Math.floor((originX + x) / tileWidth);
    return this.roundX(mapX);
  };

  /**
   * Gets a map coordinate from a screen coordinate.
   * @param {Number} y The screen coordinate
   * @return The Y position of the tile below the screen Y given.
   */
  Game_Map.prototype.canvasToMapY = function(y) {
    var tileHeight = this.tileHeight() * this.zoom.y;
    var originY = this.displayY() * tileHeight;
    var mapY = Math.floor((originY + y) / tileHeight);
    return this.roundY(mapY);
  };

  // Zoom property
  Game_Map.prototype.__defineGetter__('zoom', function() { return this._zoom; });

  //-----------------------------------------------------------------------------
  // Game_Player
  //
  // Player character class. Changed to fix the screen center/scroll while 
  // zoomming.

  // Alias
  var _GamePlayer_centerX = Game_Player.prototype.centerX;
  var _GamePlayer_centerY = Game_Player.prototype.centerY;
  var _GamePlayer_updateScroll = Game_Player.prototype.updateScroll;

  Game_Player.prototype.centerX = function() {
    return _GamePlayer_centerX.call(this) / $gameMap.zoom.x;
  };

  Game_Player.prototype.centerY = function() {
    return _GamePlayer_centerY.call(this) / $gameMap.zoom.y;
  };

  Game_Player.prototype.updateScroll = function(lastScrolledX, lastScrolledY) {
    if (!$gameMap._zoomCenter || $gameMap._zoomCenter === this) 
        _GamePlayer_updateScroll.apply(this, arguments);
  };

  //-----------------------------------------------------------------------------
  // Game_Event
  //
  // Game events class. Changed it to center the screen into the event when it's 
  // given as the zoomCenter for $gameMap.

  var Game_Event_update = Game_Event.prototype.update;

  // Copies the Game_Player scroll update function into the event class
  Game_Event.prototype.centerX = Game_Player.prototype.centerX;
  Game_Event.prototype.centerY = Game_Player.prototype.centerY;
  Game_Event.prototype.updateScroll = Game_Player.prototype.updateScroll;

  Game_Event.prototype.update = function() {
    var lastScrolledX = this.scrolledX();
    var lastScrolledY = this.scrolledY();
    Game_Event_update.apply(this, arguments);
    if (this === $gameMap._zoomCenter)
        this.updateScroll(lastScrolledX, lastScrolledY);
  };

  //-----------------------------------------------------------------------------
  // Spriteset_Map
  //
  // Map spriteset. This is where the real zooming happens.

  // Alias
  var _SpritesetMap_createLowLayer = Spriteset_Map.prototype.createLowerLayer;
  var _SpritesetMap_update = Spriteset_Map.prototype.update;

  Spriteset_Map.prototype.createLowerLayer = function() {
    _SpritesetMap_createLowLayer.apply(this, arguments);
    $gameMap.setZoom($gameMap.zoom.x, $gameMap.zoom.y, 1);
  };

  Spriteset_Map.prototype.updatePosition = function() {
    var scale = $gameMap.zoom;
    var screen = $gameScreen;
    this.x = Math.round(-$gameMap.zoom.x * (scale.x - 1));
    this.y = Math.round(-$gameMap.zoom.y * (scale.x - 1));
    this.x += Math.round(screen.shake());
    if (this.scale.x !== scale.x || this.scale.y !== scale.y) {
        var destScale = $gameMap._destZoom;
        var sw = Graphics.width / destScale.x + this._tilemap._margin * 2;
        var sh = Graphics.height / destScale.y + this._tilemap._margin * 2;
        if ((this.scale.x > destScale.x || this.scale.y > destScale.y) && !(this.width === sw && this.height === sh)) {
            //var w = $gameMap.width() * $gameMap.tileWidth() + this._tilemap._margin * 2;
            //var h = $gameMap.height() * $gameMap.tileHeight() + this._tilemap._margin * 2;
            var r = sw > this._tilemap.width || sh > this._tilemap.height;

            if (r) {
                this._tilemap.width = sw;//Math.max(w, sw);
                this._tilemap.height = sh;//Math.max(h, sh);
                this._tilemap.refresh();
            }

        }
        this.scale = new PIXI.Point(scale.x, scale.y);
        this._pictureContainer.scale = new PIXI.Point(1.0 / scale.x,  1.0 / scale.y);
        this._weather.scale = new PIXI.Point(1.0 / scale.x,  1.0 / scale.y);
        this._parallax.move(this._parallax.x, this._parallax.y, Graphics.width / scale.x, Graphics.height / scale.y);
    }
  };

  //-----------------------------------------------------------------------------
  // Tilemap
  //

  Tilemap.prototype._createLayers = function() {
    var width = this._width;
    var height = this._height;
    var margin = this._margin;
    var tileCols = Math.ceil(width / this._tileWidth) + 1;
    var tileRows = Math.ceil(height / this._tileHeight) + 1;
    var layerWidth = tileCols * this._tileWidth;
    var layerHeight = tileRows * this._tileHeight;

    if (this._lowerBitmap) {
        this._lowerBitmap.clear();
        this._lowerBitmap.resize(layerWidth, layerHeight);
    } else
        this._lowerBitmap = new Bitmap(layerWidth, layerHeight);

    if (this._upperBitmap) {
        this._upperBitmap.clear();
        this._upperBitmap.resize(layerWidth, layerHeight);
    }
    else
        this._upperBitmap = new Bitmap(layerWidth, layerHeight);

    this._layerWidth = layerWidth;
    this._layerHeight = layerHeight;

    this._lowerLayer = this._lowerLayer || new Sprite();
    this._lowerLayer.removeChildren();
    this._lowerLayer.move(-margin, -margin, width, height);
    this._lowerLayer.z = 0;

    this._upperLayer = this._upperLayer || new Sprite();
    this._upperLayer.removeChildren();
    this._upperLayer.move(-margin, -margin, width, height);
    this._upperLayer.z = 4;

    for (var i = 0; i < 4; i++) {
        this._lowerLayer.addChild(new Sprite(this._lowerBitmap));
        this._upperLayer.addChild(new Sprite(this._upperBitmap));
    }

    this.addChild(this._lowerLayer);
    this.addChild(this._upperLayer);
  };

  //-----------------------------------------------------------------------------
  // Game_Picture
  //
  // Game pictures object. Changed to apply zoom on images marked with [Zoom].

  var _GamePicture_update = Game_Picture.prototype.update;

  Game_Picture.prototype.update = function() {
      _GamePicture_update.apply(this, arguments)
      if (this.mapZoom()) this.updateZoom();
  };

  Game_Picture.prototype.updateZoom = function() {
    if (this._duration > 0) {
      var d = this._duration;
      this._scaleX = (this._scaleX  * (d - 1) + this._targetScaleX)  / d * $gameMap.zoom.x;
      this._scaleY = (this._scaleX  * (d - 1) + this._targetScaleX)  / d * $gameMap.zoom.y;
    } else {
        this._scaleX = this._targetScaleX * $gameMap.zoom.x;
        this._scaleY = this._targetScaleY * $gameMap.zoom.y;
    }
  };

  Game_Picture.prototype.mapZoom = function() {
    return !!this.name().match(/\[zoom\]/i);
  };

  //-----------------------------------------------------------------------------
  // Game_Map
  //

  Game_Map.prototype.screenTileX = function() {
    return Graphics.width / this.tileWidth() / $gameMap.zoom.x;
  };

  Game_Map.prototype.screenTileY = function() {
    return Graphics.height / this.tileHeight() / $gameMap.zoom.y;
  };

  //-----------------------------------------------------------------------------
  // Plugin command
  //

  // Alias
  var _GameInterpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;

  Game_Interpreter.prototype.pluginCommand = function (command, args) {
      _GameInterpreter_pluginCommand.call(this, command, args);
      if (command == "MapZoom") {
        if (args[0] == "set") {
            if (args[1]) {
              if (args[2]) {
                  if (args[2] == "duration") {
                      if (args[3]) {
                          $gameMap.setZoom(Number(args[1]) * $.Param.defaultZoom, Number(args[1]) * $.Param.defaultZoom, Number(args[3]));
                      }
                  } else {
                      if (args[3] == "duration") {
                          if (args[4]) {
                              $gameMap.setZoom(Number(args[1]) * $.Param.defaultZoom, Number(args[2]) * $.Param.defaultZoom, Number(args[4]));
                          }
                      } else {
                          $gameMap.setZoom(Number(args[1]) * $.Param.defaultZoom, Number(args[2]) * $.Param.defaultZoom);
                      }
                  }
              } else {
                  $gameMap.setZoom(Number(args[1]));
              }
            }
        } else if (args[0] == "reset") {
            if (args[1]) {
                $gameMap.setZoom($.Param.defaultZoom, $.Param.defaultZoom, Number(args[1]));
            } else {
                $gameMap.setZoom($.Param.defaultZoom);
            }
        $gameMap.setZoomCenter();
        } else if (args[0] == "center") {
            if (args[1] == "event") {
                var ev = $gameMap.event(Number(args[2]));
                if (ev)
                    $gameMap.setZoomCenter(ev);
            } else if (args[1] == "reset") {
                $gameMap.setZoomCenter();
            } else {
                $gameMap.setZoomCenter(Number(args[1]), Number(args[2]));
            }
        $gameMap.setZoom($gameMap._destZoom.x, $gameMap._destZoom.y, $gameMap._zoomDuration - $gameMap._spdZoom);
        }
      }
  };

})(MBS.MapZoom);

if (Imported["MVCommons"]) {
  PluginManager.register("MBS_MapZoom", 1.3, "Makes it possible to zoom in and out the game map whenever you want", {  
      email: "masked.rpg@gmail.com",
      name: "Masked", 
      website: "N/A"
    }, "2016-07-26");
}

 

 

 

 

 

 

 

 

■ 질문전 필독!
  • 질문할 내용이 이 게시판이나 강좌에 이미 있는지 확인합니다.
  • 하나의 게시물에는 하나의 질문만 합니다.
  • 제목은 질문의 핵심 내용으로 작성합니다.
  • 질문 내용은 답변자가 쉽게 이해할 수 있도록 최대한 상세하게 작성합니다.
  • 스크립트의 전문이 필요할 경우 txt 파일 등으로 첨부해 주시기 바랍니다.
  • 답변받은 게시물은 삭제하지 않습니다.
  • 답변이 완료된 경우 해당 답변해주신 분들께 감사의 댓글을 달아줍니다.
    • 처음 오신 분들은 공지 게시물을 반드시 읽어주세요!

※ 미준수시 사전경고 없이 게시물을 삭제합니다.


List of Articles
종류 분류 제목 글쓴이 날짜 조회 수
공지 묻고 답하기 가이드 습작 2014.06.14 12441
RMMV YEP의 Free Grid Plugin을 꼭 실행하고 싶.은.데.!!!! 버전이 요구하는 버전보다 이하라는 콘솔창이 계속 뜹니다!! ㅜㅜ 3 파란소리 2017.12.31 203
턴제 전투 RMMV [MV] 전투 중 몬스터 부활기능 4 BMsoft 2020.12.11 291
RMMV [MV] [툴 내 이벤트] 이벤트 구현 후 원래의 장소로 장소이동하는 방법 2 이니군 2017.08.31 169
기본툴 사용법 RMMV [MV] 그림 표시 질문드립니다. 2 BMsoft 2020.12.30 152
스크립트 작성 RMMV [mv] 능력치 + -, 스크립트의 어디를 건들여야 할까요? 2 비형 2019.05.16 120
기본툴 사용법 RMMV [mv] 설정에 '명령 기억'은 어떤 기능입니까? 2 비형 2019.05.16 165
스크립트 작성 RMMV [mv] 조건분기-> 버튼입력-> esc입력시, 마우스 우클릭 질문드립니다. 비형 2019.05.16 91
RMMV [MV] 타게임처럼 전투할때 엑터들 초상화가 뜨게 하고 싶은데 어떡하나요? 1 메탈유 2017.11.21 214
게임 배포 RMMV [MV]배포관련 질문 6 BMsoft 2020.12.13 330
RMMV [MV버전] 동영상 제어, url 링크 가능 여부 질문 2 오렌지셩 2016.05.06 221
RMMV [RPG maker MV]걸음 수에 따른 이벤트 발생 방법을 문의 드립니다. 8 파란소리 2018.02.02 309
RMMV [RPG Maker MV]조건 분기로 타이머가 0이 되면 이벤트(NPC)를 이동 루트로 내려오게 하고시퍼요 14 TTyun 2018.06.07 678
RMMV [RPG MV] 기본 전투를 엔카운터 형식의 SRPG로 외주 비용 질문. 2 안경포스 2016.02.19 464
RMMV [스크립트] 앞부분 padding과 가운데 정렬 1 file 몽롱하다 2018.01.22 141
RMMV [스크립트] 파티 멤버 체력 퍼센트 감소시 사망 안하게 하는방법 2 몽롱하다 2018.09.11 94
기본툴 사용법 RMMV [알만툴MV] 화면 비율을 16:9로 변경했는데 화면이 검은색으로 잘립니다 3 file 지수방정식 2023.06.11 320
RMMV [자바스크립트] 메시지창이 게이지 위에 뜨게하기 6 file 몽롱하다 2018.09.09 191
턴제 전투 RMMV [턴제전투] 스킬에 쿨타임을 만들고 싶습니다. 4 육식산양 2019.09.24 173
RMMV [플러그인 찾아요..ㅠㅠ] A버튼을 눌러 빨리감기... 가시밭 2017.03.23 178
RMMV [해결] XBOX컨트롤러(조이스틱)으로 쯔꾸르 게임하는법 8 NewSet 2018.05.18 4377
Board Pagination Prev 1 ... 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 ... 82 Next
/ 82