查看: 6892|回复: 19

[有事请教] 关于插件编写

[复制链接]
梦石
0
星屑
1422
在线时间
112 小时
注册时间
2011-8-17
回帖
37
发表于 2017-11-2 16:41:54 | 显示全部楼层 |阅读模式

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

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

×
我没有学过编程,可能描述的不清楚。
@param 设置的参数,后面怎么调用?
例如,我设置的是图片,怎么使用这个设置呢。
我看插件编写教程,设置背景图片的那个里,他是这么写的
this._backgroundSprite.bitmap=ImageManager.loadParallax(imageName)
我想让他直接调用我设置的图片,这么写了
this._backgroundSprite.bitmap=ImageManager('XXXX')
可是不好使啊,究竟该怎么做呢?
梦石
0
星屑
1044
在线时间
251 小时
注册时间
2016-9-2
回帖
116
发表于 2017-11-2 17:39:47 | 显示全部楼层
借助别人的代码回答问题=w=
  1. var parameters        = PluginManager.parameters('VIPArcher_Bubble_Message');
  2. 获取名字为VIPArcher_Bubble_Message的脚本参数的一个集
  3. parameters['BubbleTagName']获取名字为BubbleTagName的参数
复制代码

至于第二个问题,ImageManager.loadParallax(imageName) 是一个特殊定义的方法,它才可以直接使用图片名称
  1. ImageManager.loadParallax = function(filename, hue) {
  2.     return this.loadBitmap('img/parallaxes/', filename, hue, true);
  3. };
复制代码

这是它的定义,同理你可以使用
ImageManager.loadBitmap('路径','图片名称')来作为图片的设置
回复

使用道具 举报

梦石
0
星屑
1422
在线时间
112 小时
注册时间
2011-8-17
回帖
37
 楼主| 发表于 2017-11-2 20:24:50 | 显示全部楼层
雪在燃 发表于 2017-11-2 17:39
借助别人的代码回答问题=w=

至于第二个问题,ImageManager.loadParallax(imageName) 是一个特殊定义的方法 ...

我想写成这样的,就不能用imagemanager了吧?
还是不该这么写,我究竟得怎么办。
[pre lang="javascript" line="1"]/*:
* @plugindesc 主菜单管理
* @author 来自网络教程
* @help


* @param 背景图片设置
* @type struct<list1>[]
* @desc 可选项
* @default []

* @param 菜单编辑
* @desc 可选项
* @type struct<list2>[]
* @default []
*/

/*~struct~list1:

* @param 生效
* @type boolean
* @on 是
* @off 否
* @desc 否:false 是:true
* @default true

* @param 主菜单
* @type file
* @desc 主菜单背景使用的图片
* @dir img\parallaxes

* @param 物品栏
* @type file
* @desc 物品栏背景使用的图片
* @dir img\parallaxes

* @param 技能界面
* @type file
* @desc 技能界面背景使用的图片
* @dir img\parallaxes

* @param 装备界面
* @type file
* @desc 装备界面背景使用的图片
* @dir img\parallaxes

* @param 存档界面
* @type file
* @desc 存档界面背景使用的图片
* @dir img\parallaxes

* @param 其他界面
* @type file
* @desc 其他界面背景使用的图片
* @dir img\parallaxes
*/


/*~struct~list2:

* @param 生效
* @type boolean
* @on 是
* @off 否
* @desc 否:false 是:true
* @default true

* @param 名称
* @desc 显示在菜单中的名称
* @type text


* @param 命令
* @desc 英文命令
* @type text
*/


var params = PluginManager.parameters("edit_menu");

Scene_MenuBase.prototype.createBackground = function() {
    this._backgroundSprite=new Sprite();
    var imageName;
    if(this instanceof Scene_Menu){
        imageName = params["主菜单"];
    }else if(this instanceof Scene_Item){
        imageName = params["物品栏"]
    }else if(this instanceof Scene_Skill){
        imageName = params["技能界面"]
    }else if(this instanceof Scene_Equip){
        imageName = params["装备界面"]
    }else if(this instanceof Scene_Save || this instanceof  Scene_Load) {
        imageName = params["存档界面"]
    }else{
        imageName = params["其他界面"]
    }
    this._backgroundSprite.bitmap=ImageManager(imageName);
    this.addChild(this._backgroundSprite);
};


Window_MenuCommand.prototype.addOriginalCommands = function () {
    this.addCommand(params["名称"], params["命令"],params["生效"]);
};

var _Scene_Menu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function () {
    _Scene_Menu_createCommandWindow.call(this);

    this._commandWindow.setHandler(params['命令'], this.commandRename.bind(this));
};

Scene_Menu.prototype.commandRename = function () {
    this._statusWindow.setFormationMode(false);
    this._statusWindow.selectLast();
    this._statusWindow.activate();
    this._statusWindow.setHandler('ok',     this.rename_ok.bind(this));
    this._statusWindow.setHandler('cancel', this.rename_cancel.bind(this));
};
Scene_Menu.prototype.rename_ok = function() {
    SceneManager.push(Scene_Name);
    SceneManager.prepareNextScene($gameParty.menuActor()._actorId, 10);
};
Scene_Menu.prototype.rename_cancel = function() {
    this._statusWindow.deselect();
    this._commandWindow.activate();
};

Window_MenuStatus.prototype.processOk = function() {
    $gameParty.setMenuActor($gameParty.members()[this.index()]);
    Window_Selectable.prototype.processOk.call(this);
};[/pre]

回复

使用道具 举报

梦石
0
星屑
39236
在线时间
11155 小时
注册时间
2009-3-15
回帖
4768
发表于 2017-11-2 20:32:28 | 显示全部楼层
bloodship 发表于 2017-11-2 20:24
我想写成这样的,就不能用imagemanager了吧?
还是不该这么写,我究竟得怎么办。
/*:

字符不是要用'符号?

点评

他说:this is a static class  发表于 2017-11-2 20:47
回复

使用道具 举报

梦石
0
星屑
1422
在线时间
112 小时
注册时间
2011-8-17
回帖
37
 楼主| 发表于 2017-11-2 20:38:41 | 显示全部楼层
soulsaga 发表于 2017-11-2 20:32
字符不是要用'符号?

好的,我改成单引号。
回复

使用道具 举报

梦石
0
星屑
1044
在线时间
251 小时
注册时间
2016-9-2
回帖
116
发表于 2017-11-2 20:47:06 | 显示全部楼层
bloodship 发表于 2017-11-2 20:24
我想写成这样的,就不能用imagemanager了吧?
还是不该这么写,我究竟得怎么办。
/*:

可以用imagemanager,
也可以单独写一个自定义的方法
  1. ImageManager.loadxxx = function(filename, hue) {
  2.     return this.loadBitmap('img/xxx/', filename, hue, true);
  3. };
复制代码

这样应该就可以用ImageManager.loadxxx来访问img/xxx路径下的代码了

点评

imagemanager是不是只能使用图片的名字啊,设置路径选择的图片他可以用吗?  发表于 2017-11-2 21:19
回复

使用道具 举报

梦石
0
星屑
1422
在线时间
112 小时
注册时间
2011-8-17
回帖
37
 楼主| 发表于 2017-11-2 20:55:04 | 显示全部楼层
本帖最后由 bloodship 于 2017-11-2 20:57 编辑

我重新改一下
回复

使用道具 举报

梦石
0
星屑
1422
在线时间
112 小时
注册时间
2011-8-17
回帖
37
 楼主| 发表于 2017-11-2 21:01:49 | 显示全部楼层
改成这样了,没有报错,但是背景是黑色的,应该是没有选择到图
[pre lang="javascript" line="0"]var params = PluginManager.parameters("edit_menu");

Scene_MenuBase.prototype.createBackground = function() {
    this._backgroundSprite=new Sprite();
       
        ImageManager.loadParallax = function(filename, hue) {
    return this.loadBitmap('img/Parallax/', filename, hue, true);
     };
         
    var imageName;
    if(this instanceof Scene_Menu){
        imageName = params['主菜单'];
    }else if(this instanceof Scene_Item){
        imageName = params['物品栏']
    }else if(this instanceof Scene_Skill){
        imageName = params['技能界面']
    }else if(this instanceof Scene_Equip){
        imageName = params['装备界面']
    }else if(this instanceof Scene_Save || this instanceof  Scene_Load) {
        imageName = params['存档界面']
    }else{
        imageName = params['其他界面']
    }
    this._backgroundSprite.bitmap=ImageManager.loadParallax(imageName);
    this.addChild(this._backgroundSprite);
};[/pre]

回复

使用道具 举报

梦石
0
星屑
1044
在线时间
251 小时
注册时间
2016-9-2
回帖
116
发表于 2017-11-2 21:30:34 | 显示全部楼层
bloodship 发表于 2017-11-2 21:01
改成这样了,没有报错,但是背景是黑色的,应该是没有选择到图
var params = PluginManager.parameters("ed ...

没有对应的图片,你可以放一张图片在img/parallax文件夹下,然后把imageName = '文件名'
应该就没有问题了
回复

使用道具 举报

梦石
0
星屑
1422
在线时间
112 小时
注册时间
2011-8-17
回帖
37
 楼主| 发表于 2017-11-2 21:37:44 | 显示全部楼层
雪在燃 发表于 2017-11-2 21:30
没有对应的图片,你可以放一张图片在img/parallax文件夹下,然后把imageName = '文件名'
应该就没有问题 ...

对,就是你说的这个症状!
我练习一下,所以就改教程了。我想在插件界面选择图片就可以直接设置背景,不用编辑插件。我的想法不能用imagemanager吧?

[pre lang="javascript" line="0"]/*:
* @plugindesc 主菜单管理
* @author 来自网络教程
* @help


* @param 背景图片设置
* @type struct<list1>[]
* @desc 可选项
* @default []

* @param 菜单编辑
* @desc 可选项
* @type struct<list2>[]
* @default []
*/

/*~struct~list1:

* @param 生效
* @type boolean
* @on 是
* @off 否
* @desc 否:false 是:true
* @default true

* @param 主菜单
* @type file
* @desc 主菜单背景使用的图片
* @dir img\parallaxes

* @param 物品栏
* @type file
* @desc 物品栏背景使用的图片
* @dir img\parallaxes

* @param 技能界面
* @type file
* @desc 技能界面背景使用的图片
* @dir img\parallaxes

* @param 装备界面
* @type file
* @desc 装备界面背景使用的图片
* @dir img\parallaxes

* @param 存档界面
* @type file
* @desc 存档界面背景使用的图片
* @dir img\parallaxes

* @param 其他界面
* @type file
* @desc 其他界面背景使用的图片
* @dir img\parallaxes
*/


/*~struct~list2:

* @param 生效
* @type boolean
* @on 是
* @off 否
* @desc 否:false 是:true
* @default true

* @param 名称
* @desc 显示在菜单中的名称
* @type text


* @param 命令
* @desc 英文命令
* @type text
*/

var params = PluginManager.parameters("edit_menu");

Scene_MenuBase.prototype.createBackground = function() {
    this._backgroundSprite=new Sprite();
       
        ImageManager.loadParallax = function(filename, hue) {
    return this.loadBitmap('img/Parallax/', filename, hue, true);
     };
         
    var imageName;
    if(this instanceof Scene_Menu){
        imageName = params['主菜单'];
    }else if(this instanceof Scene_Item){
        imageName = params['物品栏']
    }else if(this instanceof Scene_Skill){
        imageName = params['技能界面']
    }else if(this instanceof Scene_Equip){
        imageName = params['装备界面']
    }else if(this instanceof Scene_Save || this instanceof  Scene_Load) {
        imageName = params['存档界面']
    }else{
        imageName = params['其他界面']
    }
    this._backgroundSprite.bitmap=ImageManager.loadParallax(imageName);
    this.addChild(this._backgroundSprite);
};


Window_MenuCommand.prototype.addOriginalCommands = function () {
    this.addCommand(params['名称'], params['命令'],true);
};

var _Scene_Menu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function () {
    _Scene_Menu_createCommandWindow.call(this);

    this._commandWindow.setHandler(params['命令'], this.commandRename.bind(this));
};

Scene_Menu.prototype.commandRename = function () {
    this._statusWindow.setFormationMode(false);
    this._statusWindow.selectLast();
    this._statusWindow.activate();
    this._statusWindow.setHandler('ok',     this.rename_ok.bind(this));
    this._statusWindow.setHandler('cancel', this.rename_cancel.bind(this));
};
Scene_Menu.prototype.rename_ok = function() {
    SceneManager.push(Scene_Name);
    SceneManager.prepareNextScene($gameParty.menuActor()._actorId, 10);
};
Scene_Menu.prototype.rename_cancel = function() {
    this._statusWindow.deselect();
    this._commandWindow.activate();
};

Window_MenuStatus.prototype.processOk = function() {
    $gameParty.setMenuActor($gameParty.members()[this.index()]);
    Window_Selectable.prototype.processOk.call(this);
};[/pre]


回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部