设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 128|回复: 2
打印 上一主题 下一主题

[有事请教] 已解决问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
169
在线时间
48 小时
注册时间
2023-12-19
帖子
14
跳转到指定楼层
1
发表于 2024-4-28 18:29:27 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 crp 于 2024-4-29 14:16 编辑

已解决问题

联想截图_20240428182525.png (65.05 KB, 下载次数: 10)

联想截图_20240428182525.png

联想截图_20240428182832.png (84.45 KB, 下载次数: 10)

联想截图_20240428182832.png

Lv1.梦旅人

梦石
0
星屑
169
在线时间
48 小时
注册时间
2023-12-19
帖子
14
2
 楼主| 发表于 2024-4-28 18:31:05 | 只看该作者
像p1单独命名的话只能显示命名的那张背景,物品菜单的背景就没法显示了。求大佬指点
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
169
在线时间
48 小时
注册时间
2023-12-19
帖子
14
3
 楼主| 发表于 2024-4-29 02:36:05 | 只看该作者
代码出错:Cannot read property '0' of undefined,有大佬知道是什么原因吗

//=============================================================================
// MOG_MenuBackground.js
//=============================================================================
/*:
* @target MZ
* @plugindesc (v1.0) O plugin permite mudar a imagem de fundo do menu.
* @author Moghunter
* @url https://mogplugins.wordpress.com
*
* @param Default FileName
* @text File Name
* @desc Definição do nome de arquivo.
* @type file
* @dir img/menus/
* @default Background_01
*
* @param Window Opacity
* @desc Definição da transparência da janela.
* @type number
* @default 0
* @min 0
* @max 255
*
* @param Scroll X-Axis
* @desc Definição da velocidade de deslize na horizontal.
* @default 0
*
* @param Scroll Y-Axis
* @desc Definição da velocidade de deslize na vertical.
* @default 0
*
* @param Disable Scenes
* @desc Definição das cenas que terão o efeito desativado.
* Scene_Name1 , Scene_Name2 , Scene_Name3 ...
* @default Scene_Test1,Scene_Test2,Scene_Test3
*
* @command MenuBackground_Setup
* @desc Configuração do fundo do menu.
* @text Setup
*
* @arg fileName
* @text File Name
* @desc Definição do nome de arquivo.
* @type file
* @dir img/menus/
* @default Background_01
*
* @arg sx
* @text Horizontal Scroll
* @desc Definição da velocidade de deslize na horizontal.
* @default 0
*
* @arg sy
* @text Vertical Scroll
* @desc Definição da velocidade do deslize na vertical.
* @default 0
*
* @help
* =============================================================================
* ♦♦♦ MOG - Menu Background ♦♦♦
* Author   -   Moghunter
* Version  -   1.0
* Updated  -   2020/10/18
* https://mogplugins.wordpress.com
* =============================================================================
* O plugin permite mudar a imagem de fundo do menu.
*
* =============================================================================
* As imagens do background deverão ficar na pasta /img/menus/
* =============================================================================
*
*/
(() => {
       
//=============================================================================
// ** PLUGIN PARAMETERS
//=============================================================================
  var Imported = Imported || {};
  Imported.MOG_MenuBackground = true;
  var Moghunter = Moghunter || {};

   Moghunter.parameters = PluginManager.parameters('MOG_MenuBackground');
    Moghunter.mback_fileName = String(Moghunter.parameters['Default FileName'] || "Background_01");
        Moghunter.mback_sufixName = String(Moghunter.parameters['Suffix FileName'] || "_back");
    Moghunter.mback_selfback = String(Moghunter.parameters['Unique Backgrounds'] || "false");
        Moghunter.mback_skipscenes = Object(Moghunter.parameters['Disable Scenes'] || []);
        Moghunter.mback_ox = Number(Moghunter.parameters['Scroll X-Axis'] || 0);
        Moghunter.mback_oy = Number(Moghunter.parameters['Scroll Y-Axis'] || 0);
        Moghunter.mback_opacity = Number(Moghunter.parameters['Window Opacity'] || 0);
        SceneManager._mback = false;
       
//==============================
// * Setup Command
//==============================
PluginManager.registerCommand('MOG_MenuBackground', "MenuBackground_Setup", data => {
        const fileName = String(data.fileName);
        const sx = Number(data.sx);
        const sy = Number(data.sy);
        $gameSystem._menuBackgroundData.fileName = fileName;
        $gameSystem._menuBackgroundData.sx = sx;
        $gameSystem._menuBackgroundData.sy = sy;
        SceneManager.setMenuBackgroundBitmap(true);
});       
       
//=============================================================================
// ■■■ ImageManager ■■■
//=============================================================================

//==============================
// * Menus
//==============================
ImageManager.loadMenus = function(filename) {
    return this.loadBitmap('img/menus/', filename);
};

//=============================================================================
// ■■■ Game System ■■■
//=============================================================================

//==============================
// ♦ ALIAS ♦  Initialize
//==============================
const _mog_menuBackground_gSystem_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
        _mog_menuBackground_gSystem_initialize.call(this);
        this.setupMenuBackground();
};

//==============================
// * setup Menu Background
//==============================
Game_System.prototype.setupMenuBackground = function() {
        this._menuBackgroundData = {};
        this._menuBackgroundData.fileName = String(Moghunter.mback_fileName);
        this._menuBackgroundData.sx = Moghunter.mback_ox;
        this._menuBackgroundData.sy = Moghunter.mback_oy;
        this._menuBackgroundData.needRefresh = false;
};

//==============================
// * Get Par Array
//==============================
Game_System.prototype.get_par_array = function(object,value,type) {
        if (value.length === 0) {return};
        var s = value.split(',');
        if (type === 0){
                for (var i = 0; i < s.length; i++) {object.push(String(s[i]));        };
        } else {
            for (var i = 0; i < s.length; i++) {object.push(Number(s[i]));        };
   };
};

//=============================================================================
// ■■■ Window Base ■■■
//=============================================================================

//==============================
// ♦ ALIAS ♦  Initialize
//==============================
const _mog_menuBack_wbase_initialize = Window_Base.prototype.initialize;
Window_Base.prototype.initialize = function(rect) {
        _mog_menuBack_wbase_initialize.call(this,rect);
         if (this.needUpdateBackOpacity()) {this.updateBackgroundOpacity()};
};

//==============================
// ♦ ALIAS ♦  Update
//==============================
const _alias_mog_mback_wbase_update = Window_Base.prototype.update;
Window_Base.prototype.update = function() {
        _alias_mog_mback_wbase_update.call(this);
    if (this.needUpdateBackOpacity()) {this.updateBackgroundOpacity()};
};

//==============================
// * Need Update Back Opacity
//==============================
Window_Base.prototype.needUpdateBackOpacity = function() {
   if (!SceneManager._mback) {return false};
   return true;
};

//==============================
// * Update Background Opacity
//==============================
Window_Base.prototype.updateBackgroundOpacity = function() {
    this.opacity = Moghunter.mback_opacity;
};

//=============================================================================
// ■■■ Scene MenuBase ■■■
//=============================================================================

//==============================
// * Skip Mbackground
//==============================
Scene_MenuBase.prototype.needSkipBackgroundScene = function() {
        if (!SceneManager._scene) {return false};
        this._mb_skip_scenes = [];
        $gameSystem.get_par_array(this._mb_skip_scenes, Moghunter.mback_skipscenes, 0);
           for (var i = 0; i < this._mb_skip_scenes.length; i++) {
                if (this._mb_skip_scenes[i] === SceneManager._scene.constructor.name) {return true};
        };       
    return false;
};

//==============================
// ♦ ALIAS ♦  Terminate
//==============================
const _alias_mog_mback_scmb_terminate = Scene_MenuBase.prototype.terminate;
Scene_MenuBase.prototype.terminate = function() {
        _alias_mog_mback_scmb_terminate.call(this);
        SceneManager._mback = false;       
};

//==============================
// ♦♦♦ ALIAS ♦♦♦  createBackground
//==============================
const _mog_menuBack_scnMenuBase_createBackground = Scene_MenuBase.prototype.createBackground;
Scene_MenuBase.prototype.createBackground = function() {
         SceneManager._mback = false;
         if (!this.needSkipBackgroundScene()) {this.createBackground2();return};
        _mog_menuBack_scnMenuBase_createBackground.call(this);
};

//==============================
// ♦♦♦ ALIAS ♦♦♦  createBackground
//==============================
Scene_MenuBase.prototype.createBackground2 = function() {
        SceneManager._mback = true;
    this._backgroundSprite = new TilingSprite();
        this._backgroundSprite.move(0, 0, Graphics.width, Graphics.height);                       
    this.refreshBackgroundBitmap();
    this.addChild(this._backgroundSprite);
        if (this.needResizeBackground()) {this.resizeBackground(true)};
};

//==============================
// * refresh Background Bitmap
//==============================
Scene_MenuBase.prototype.refreshBackgroundBitmap = function() {
        this._backgroundSpriteName = $gameSystem ? $gameSystem._menuBackgroundData.fileName : "";
    this._backgroundSprite.bitmap = SceneManager.backgroundMenuBitmap();
        this._backgroundSprite.visible = false;
        this._backgroundSpriteResize = true;
};

//==============================
// * need Resize Background
//==============================
Scene_MenuBase.prototype.needResizeBackground = function() {
        if (!this._backgroundSprite) {return false};
        if (!this._backgroundSpriteResize) {return false}
        if (!this._backgroundSprite.bitmap.isReady()) {return false};
        return true;
};

//==============================
// * resize Background
//==============================
Scene_MenuBase.prototype.resizeBackground = function() {
        this._backgroundSpriteResize = false
        this._backgroundSprite.visible = true;
        this._backgroundSprite.scale.x = Graphics.width / this._backgroundSprite.bitmap.width;
        this._backgroundSprite.scale.y = Graphics.height / this._backgroundSprite.bitmap.height;
        this._backgroundSprite.move(0, 0, this._backgroundSprite.bitmap.width, this._backgroundSprite.bitmap.height);         
};

//==============================
// * update Menu Background
//==============================
Scene_MenuBase.prototype.updateMenuBackground = function() {
        this._backgroundSprite.origin.x += $gameSystem._menuBackgroundData.sx;
        this._backgroundSprite.origin.y += $gameSystem._menuBackgroundData.sy;
        if (this.needResizeBackground()) {this.resizeBackground()};
        if (this.needRefreshBackground()) {       
            SceneManager.setMenuBackgroundBitmap(false);
            this.refreshBackgroundBitmap();
        };
};

//==============================
// * needRefreshBackground
//==============================
Scene_MenuBase.prototype.needRefreshBackground = function() {
        if (!$gameSystem) {return false}
        if (this._backgroundSpriteName != $gameSystem._menuBackgroundData.fileName) {return true};
        return false;
};

//==============================
// ♦ ALIAS ♦  Update
//==============================
const _mog_mback_scbase_update = Scene_MenuBase.prototype.update;
Scene_MenuBase.prototype.update = function() {
        _mog_mback_scbase_update.call(this);
        if (this._backgroundSprite) {this.updateMenuBackground()};
};

//=============================================================================
// ■■■ Scene Map ■■■
//=============================================================================

//==============================
// ♦ ALIAS ♦  Terminate
//==============================
const _mog_menuBack_scnMap_terminate = Scene_Map.prototype.terminate;
Scene_Map.prototype.terminate = function() {
         _mog_menuBack_scnMap_terminate.call(this);
           SceneManager.setMenuBackgroundBitmap(false);
};

//==============================
// ♦ ALIAS ♦  call Menu
//==============================
const _mog_menuBack_scnMap_callMenu = Scene_Map.prototype.callMenu;
Scene_Map.prototype.callMenu = function() {
          _mog_menuBack_scnMap_callMenu.call(this);
          SceneManager.setMenuBackgroundBitmap(false);
};

//=============================================================================
// ■■■ Scene Manager ■■■
//=============================================================================

//==============================
// ♦ ALIAS ♦  initialize
//==============================
const _mog_menuBack_scnMngr_initialize = SceneManager.initialize;
SceneManager.initialize = function() {
          _mog_menuBack_scnMngr_initialize.call(this);
          this.setMenuBackgroundBitmap(false);
};
   
//==============================
// * backgroundName
//==============================  
SceneManager.backgroundName = function() {
   if ($gameSystem) {return String($gameSystem._menuBackgroundData.fileName)};
   return String(Moghunter.mback_fileName);
};

//==============================
// * setMenuBackgroundBitmap
//==============================
SceneManager.setMenuBackgroundBitmap = function(name,destroy) {
        if (this._backgroundMenuBitmap && destroy) {
            this._backgroundMenuBitmap.destroy();
        }
        this._backgroundMenuBitmap = ImageManager.loadMenus(this.backgroundName());
};

//==============================
// * backgroundMenuBitmap
//==============================
SceneManager.backgroundMenuBitmap = function() {
         return this._backgroundMenuBitmap;
};

})();
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-13 15:48

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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