じ☆ve冰风 发表于 2024-2-13 14:54:17

对话框跟随角色 =-= 改进中(已适配 YEP_MessageCore )

不支持1.3版本,不支持1.3版本,奇怪的bug,请勿使用!




https://rpg.blue/data/attachment/forum/201512/12/030155iydlv5b9jbf99wlh.jpg


代码下载地址:http://pan.baidu.com/s/1pJVMRl5

不知道是不是大家都选择使用YEP_messageCore,现出一个针对它的优化版本,具体请看注释。//=============================================================================
//fuki.js
//=============================================================================
/**
* @Author:      Garfeng Gu
* @Email:      
* @CreateTime:2015-12-12 21:44:12
* @LastModified:2015-12-16 20:18:19

* @Description: 呼出对话框 for RPG Maker MV
*               在使用时,添加[文本显示],填写\fuki正文内容,即可在游
*               戏里将对话框定位到相应角色上方,eventId设为0时,对应主角。
*               如:\fuki你好,阿尔西斯。
*               强烈推荐使用下方页面的自动换行脚本:
*               https://rpg.blue/thread-386230-1-1.html
*               本代码已适配YEP_Message,使用方法请参考下方对应函数处的注释。

* @License:   No part of this source code could be used for commercial/business
*               purpose without the express written permission of Garfeng Gu.
*/



/*没有使用YEP_MessageCore则删掉本行
//没有使用YEP_MessageCore的童鞋请将这一段的注释删掉
Window_Message.prototype.startMessage = function()
{
    this._textState = {};
    this._textState.index = 0;
    var text = this.convertEscapeCharacters($gameMessage.allText());
    text = this.getFukiId(text);
    this._textState.text = text;
    this.newPage(this._textState);
    this.updatePlacement();
    this.updateBackground();
    this.open();
}
没有使用YEP_MessageCore则删掉本行*/

/*
//使用了YEP_MessageCore的童鞋请把YEP_MessageCore里的
//Window_Message.prototype.adjustWindowSettings
//和Window_Message.prototype.convertEscapeCharacters做如下修改。
Window_Message.prototype.adjustWindowSettings = function() {
    if(this.setfuki == undefined || this.setfuki == 0){ //Add by Garfeng Gu
      this.width = this.windowWidth();
      this.height = Math.min(this.windowHeight(), Graphics.boxHeight);
      if (Math.abs(Graphics.boxHeight - this.height) < this.lineHeight()) {
            this.height = Graphics.boxHeight;
      }
      this.createContents();
      this.x = (Graphics.boxWidth - this.width) / 2;
    }//Add by Garfeng Gu
};

Window_Message.prototype.convertEscapeCharacters = function(text) {
    text = Window_Base.prototype.convertEscapeCharacters.call(this, text);
    text = this.getFukiId(text);//Add by Garfeng Gu
    text = this.convertNameBox(text);
    text = this.convertMessageCharacters(text);
    return text;
};
*/

Window_Message.prototype.updatePlacement = function() {
    if(this.setfuki == undefined || this.setfuki==0){
    this._positionType = $gameMessage.positionType();
    this.y = this._positionType * (Graphics.boxHeight - this.height) / 2;
    this._goldWindow.y = this.y > 0 ? 0 : Graphics.boxHeight - this._goldWindow.height;
}
};

Window_Message.prototype.getFukiId = function(text)
{
    //fuki
    var eventid = -1;
    text = text.replace(/\x1bFUKI\[(\d+)\]/gi,function(){
      eventid = arguments;
      return "";
    });
    if(eventid>=0){
      this.fukiPalcement(eventid);
    }
    else
    {
      this.setfuki = 0;
    }

    return text;
};


Window_Message.prototype.fukiPalcement = function (eventid)
{

      var idx,idy;
      if(eventid!=0){
            idx = $gameMap._events._x;
            idy = $gameMap._events._y;
      }
      else
      {
            idx = $gamePlayer._x;
            idy = $gamePlayer._y;
      }



      idx = $gameMap.adjustX(idx);
      idy = $gameMap.adjustY(idy);

      var width = this.windowWidth()/2;
      var height = this.windowHeight();
      var x = idx*48 + 24 - width/2;//
      var y = idy*48 - 24 - height;


      if(x+width>Graphics.boxWidth) x = (Graphics.boxWidth - width);
      else if(xGraphics.boxHeight) y = Graphics.boxHeight - height;

      else if(y
页: [1]
查看完整版本: 对话框跟随角色 =-= 改进中(已适配 YEP_MessageCore )