扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 156|回复: 0

[转载发布] 使用了纵向战斗镜头移动的插件,但是战斗背景出现问题。

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    2025-2-4 02:05
  • 签到天数: 110 天

    连续签到: 2 天

    [LV.6]常住居民II

    2327

    主题

    395

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10465
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13215

    灌水之王

    发表于 2024-2-24 14:38:49 | 显示全部楼层 |阅读模式
    如图所示,成了这副样子。

    以下是插件,能帮我解决的话,万分感谢!

    JAVASCRIPT 代码下载

    [code]//=============================================================================
    // AndrewX - Automatic Battle Camera
    // AndrewX_AutomaticBattleCamera.js
    //=============================================================================
    var Imported = Imported || {};

    var AndrewX = AndrewX || {};
    AndrewX.ABC = AndrewX.ABC || {};
    //=============================================================================
    /*:
    * @plugindesc v0.10 Automatic focus camera on target in battle.
    * @author AndrewX
    *
    * @param Camera Frame Speed
    * @desc 镜头帧速,数字越小越快。默认10
    * @default 10
    *
    * @param Zoom In Rate
    * @desc 镜头放大率。正常大小1.0,默认放大到1.1
    * @default 1.1
    *
    * @param Zoom Out Rate
    * @desc 镜头拉远率,用于全屏动画。正常大小1.0,默认缩小到0.9
    * @default 0.9
    *
    * @param Battleback Zoom Rate
    * @desc 背景增大率,避免默认素材背景在镜头移动后出现黑边所做的处理。默认1.3
    * @default 1.3
    *
    * @param Scale Battleback
    * @desc 战斗背景适应窗口。0: 不拉伸; 1: 仅在战斗背景小于屏幕尺寸时拉伸,2: 总是适应窗口。默认1
    * @default 1
    *
    * @param Zoom When Selecting
    * @desc 是否在选择目标时聚焦。true: 聚焦; false: 不聚焦。默认false
    * @default false
    *
    * @param Depth Sacle Rate
    * @desc 敌人近大远小比例,填入由空格分隔的两个小数,分别为最远(上)处比例和最近(下)处比例。默认0.5 1.2。不使用此功能则留空
    * @default 0.5 1.2
    *
    * @help
    * ============================================================================
    * Introduction and Instructions
    * ============================================================================
    *
    * 本插件实现纵版战斗镜头自动推进和拉远的效果。
    *
    * 仅适用于纵版战斗。
    *
    * Credit: 本插件思路来自芙蕾娅的VA脚本:
    * http://rpg.blue/home.php?mod=spa ... o=blog&id=13408
    * 加入选择目标时镜头跟随,战斗背景自适应,敌人近大远小功能。
    * 修正了动画位置跟随和伤害跳字跟随的问题。
    * 并且兼容Yanfly的战斗血条插件,兼容YEP_CoreEngine.js选中敌人不闪烁功能。
    *
    * 动画名称标签:
    *
    * 如果动画名称中包含“”(包括尖括号,必须大写),则该动画播放不会引发
    * 镜头效果。
    *
    * ============================================================================
    * Changelog
    * ============================================================================
    *
    * Version 0.20:
    * - New: Add  in name of animations to disable camera movement for
    *   these animations
    * - Modified: Zoom When Selecting parameter is set false as default now
    * - Minor bug fix
    *
    * Version 0.10:
    * - Finished prototype
    *
    * ============================================================================
    * Term of Use
    * ============================================================================
    *
    * Free for use in non-commercial or commercial RMMV projects
    * Please credit AndrewX & 芙蕾娅
    *
    */
    //=============================================================================


    (function(){

        var parameters = PluginManager.parameters('AndrewX_AutomaticBattleCamera');
        var cameraFrameSpeed = Number(parameters['Camera Frame Speed'] || 10);
        var zoomIn = Number(parameters['Zoom In Rate'] || 1.1);
        var zoomOut = Number(parameters['Zoom Out Rate'] || 0.9);
        var battlebackZoom = Number(parameters['Battleback Zoom Rate'] || 1.3);
        var scaleBattlebcak = Number(parameters['Scale Battleback'] || 1);
        var zoomSelect = parameters['Zoom When Selecting'] || "false"
        var depthScaleRate = (parameters['Depth Sacle Rate'] || "1.0 1.0").split(" ");
        depthScaleRate = (depthScaleRate.length < 2) ? [1, 1] : depthScaleRate;
        for(var i = 0; i < depthScaleRate.length; i++){
            depthScaleRate = Number(depthScaleRate);
            depthScaleRate = (depthScaleRate === 0) ? 1 : depthScaleRate;
        };

        function Battle_Camera(){
            this.initialize.apply(this, arguments);
        };

        Battle_Camera.prototype.initialize = function(){
            this.x = Graphics.width / 2;
            this.y = Graphics.height / 2;
            this.newX = Graphics.width / 2;
            this.newY = Graphics.height / 2;
            this.centerWidth = Graphics.width / 2;
            this.centerHeight = Graphics.height / 2;
            this.zoom = 1.0;
            this.newZoom = 1.0;
            this.frameSpeed = cameraFrameSpeed;
            this.back1OriginalX = 0;
            this.back1OriginalY = 0;
            this.back2OriginalX = 0;
            this.back2OriginalY = 0;
        };

        Battle_Camera.prototype.resetFrameSpeed = function(){
            this.frameSpeed = cameraFrameSpeed;
        };

        Battle_Camera.prototype.focusOn = function(target, zoom, speed){
            if(target.isEnemy()){
                this.resetFrameSpeed();
                this.newX = target.screenX();

                var yOffset = 0;
                var enemySprites = BattleManager._spriteset._enemySprites;
                for(var i = 0; i < enemySprites.length; i++){
                    var sprite = enemySprites;
                    if(target === sprite._battler){
                        yOffset = sprite.height / 2;
                        break;
                    }
                }
                var statusWindowHeight = 0;
                if(typeof SceneManager._scene._statusWindow !== "undefined"){
                    statusWindowHeight = SceneManager._scene._statusWindow.height
                }

                this.newY = target.screenY() - yOffset + statusWindowHeight / 2; //调节基准点
                if(!(typeof zoom === "undefined")){
                    this.newZoom = zoom;
                }
                if(!(typeof speed === "undefined")){
                    this.frameSpeed = speed;
                }
            }
        };

        Battle_Camera.prototype.center = function(zoom){
            this.newX = this.centerWidth;
            this.newY = this.centerHeight;
            if(!(zoom === undefined)){
                this.newZoom = zoom;
            }else{
                this.newZoom = 1.0;
            }
        };

        Battle_Camera.prototype.battlerX = function(battler){
            var distance = battler.screenX() - this.x;
            var value = distance * (this.zoom - 1.0);
            var pos = battler.screenX() - (this.x - this.centerWidth);
            return pos + value;
        };

        Battle_Camera.prototype.battlerY = function(battler){
            var distance = battler.screenY() - this.y;
            var value = distance * (this.zoom - 1.0);
            var pos = battler.screenY() - (this.y - this.centerHeight);
            return pos + value;
        };

        Battle_Camera.prototype.update = function(){
            if(this.x != this.newX){
                this.x = (this.newX - this.x > 0) ?
                    Math.min(this.x + this.moveSpeedX(), this.newX) :
                    Math.max(this.x - this.moveSpeedX(), this.newX);
            }
            if(this.y != this.newY){
                this.y = (this.newY - this.y > 0) ?
                    Math.min(this.y + this.moveSpeedY(), this.newY) :
                    Math.max(this.y - this.moveSpeedY(), this.newY);
            }
            if(this.zoom != this.newZoom){
                this.zoom = (this.newZoom - this.zoom > 0) ?
                    Math.min(this.zoom + this.zoomSpeed(), this.newZoom) :
                    Math.max(this.zoom - this.zoomSpeed(), this.newZoom);
            }
        };

        Battle_Camera.prototype.distanceX = function(){
            return Math.abs(this.x - this.newX);
        };

        Battle_Camera.prototype.distanceY = function(){
            return Math.abs(this.y - this.newY);
        };

        Battle_Camera.prototype.distanceZoom = function(){
            return Math.abs(this.zoom - this.newZoom);
        };

        Battle_Camera.prototype.moveSpeedX = function(){
            return Math.max(Math.floor(this.distanceX() / this.frameSpeed), 1);
        };

        Battle_Camera.prototype.moveSpeedY = function(){
            return Math.max(Math.floor(this.distanceY() / this.frameSpeed), 1);
        };

        Battle_Camera.prototype.zoomSpeed = function(){
            return Math.max(this.distanceZoom() / this.frameSpeed, 0.001);
        };

        AndrewX.ABC.updateCellSprite = Sprite_Animation.prototype.updateCellSprite;
        Sprite_Animation.prototype.updateCellSprite = function(sprite, cell){
            var pattern = cell[0];
            if(pattern >= 0){
                var sx = pattern % 5 * 192;
                var sy = Math.floor(pattern % 100 / 5) * 192;
                var mirror = this._mirror;
                sprite.bitmap = pattern < 100 ? this._bitmap1 : this._bitmap2;
                sprite.setFrame(sx, sy, 192, 192);
                sprite.x = cell[1];
                sprite.y = cell[2];
                if(this._mirror){
                    sprite.x *= -1;
                }
                if(typeof BattleManager._spriteset === "undefined"){
                    var zoom = 1
                }else{
                    var zoom = BattleManager._spriteset.battleCamera.zoom;
                }
                sprite.rotation = cell[4] * Math.PI / 180;
                sprite.scale.x = cell[3] / 100 * zoom; //here
                if((cell[5] && !mirror) || (!cell[5] && mirror)){
                    sprite.scale.x *= -1;
                }
                sprite.scale.y = cell[3] / 100 * zoom; //here
                sprite.opacity = cell[6];
                sprite.blendMode = cell[7];
                sprite.visible = this._target.visible;
            }else{
                sprite.visible = false;
            }
        };

        AndrewX.ABC.spritesetBattleInitialize = Spriteset_Battle.prototype.initialize;
        Spriteset_Battle.prototype.initialize = function(){
            this.battleCamera = new Battle_Camera();
            AndrewX.ABC.spritesetBattleInitialize.call(this);

        };

        AndrewX.ABC.spritesetBattleUpdate = Spriteset_Battle.prototype.update;
        Spriteset_Battle.prototype.update = function(){
            AndrewX.ABC.spritesetBattleUpdate.call(this);
            this.battleCamera.update();
            this.updateBattlebackPosition();
            this.updateEnemyPosition();
        };

        AndrewX.ABC.locateBattleback = Spriteset_Battle.prototype.locateBattleback;
        Spriteset_Battle.prototype.locateBattleback = function(){
            var width = this._battleField.width;
            var height = this._battleField.height;
            var sprite1 = this._back1Sprite;
            var sprite2 = this._back2Sprite;
            sprite1.origin.x = 0;
            sprite2.origin.x = 0;
            sprite1.origin.y = 0;
            sprite2.origin.y = 0;
            sprite1.anchor.x = 0.5;
            sprite1.anchor.y = 0.5;
            sprite2.anchor.x = 0.5;
            sprite2.anchor.y = 0.5;
            var x = this._battleField.width / 2;
            var y = this._battleField.height / 2;
            sprite1.move(x, y, sprite1.bitmap.width, sprite1.bitmap.height);
            sprite2.move(x, y, sprite2.bitmap.width, sprite2.bitmap.height);
            this.battleCamera.back1OriginalX = this._back1Sprite.x;
            this.battleCamera.back1OriginalY = this._back1Sprite.y;
            this.battleCamera.back2OriginalX = this._back2Sprite.x;
            this.battleCamera.back2OriginalY = this._back2Sprite.y;
        };

        Spriteset_Battle.prototype.updateBattlebackPosition = function(){
            var zoom = this.battleCamera.zoom * battlebackZoom;
            var sprite1 = this._back1Sprite;
            var sprite2 = this._back2Sprite;

            var back1ScaleX = 1;
            var back2ScaleX = 1;
            var back1ScaleY = 1;
            var back2ScaleY = 1;

            if(scaleBattlebcak === 1){
                if(!(sprite1.bitmap.width

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-3-10 19:11 , Processed in 0.129423 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表