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

Project1

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

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1422
在线时间
112 小时
注册时间
2011-8-17
帖子
43
跳转到指定楼层
1
发表于 2017-11-2 16:41:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我没有学过编程,可能描述的不清楚。
@param 设置的参数,后面怎么调用?
例如,我设置的是图片,怎么使用这个设置呢。
我看插件编写教程,设置背景图片的那个里,他是这么写的
this._backgroundSprite.bitmap=ImageManager.loadParallax(imageName)
我想让他直接调用我设置的图片,这么写了
this._backgroundSprite.bitmap=ImageManager('XXXX')
可是不好使啊,究竟该怎么做呢?

Lv3.寻梦者

梦石
0
星屑
1044
在线时间
251 小时
注册时间
2016-9-2
帖子
126
2
发表于 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('路径','图片名称')来作为图片的设置
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1422
在线时间
112 小时
注册时间
2011-8-17
帖子
43
3
 楼主| 发表于 2017-11-2 20:24:50 | 只看该作者
雪在燃 发表于 2017-11-2 17:39
借助别人的代码回答问题=w=

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

我想写成这样的,就不能用imagemanager了吧?
还是不该这么写,我究竟得怎么办。
JAVASCRIPT 代码复制
  1. /*:
  2.  * @plugindesc 主菜单管理
  3.  * @author 来自网络教程
  4.  * @help
  5.  
  6.  
  7.  * @param 背景图片设置
  8.  * @type struct<list1>[]
  9.  * @desc 可选项
  10.  * @default []
  11.  
  12.  * @param 菜单编辑
  13.  * @desc 可选项
  14.  * @type struct<list2>[]
  15.  * @default []
  16. */
  17.  
  18. /*~struct~list1:
  19.  
  20.  * @param 生效
  21.  * @type boolean
  22.  * @on 是
  23.  * @off 否
  24.  * @desc 否:false 是:true
  25.  * @default true
  26.  
  27.  * @param 主菜单
  28.  * @type file
  29.  * @desc 主菜单背景使用的图片
  30.  * @dir img\parallaxes
  31.  
  32.  * @param 物品栏
  33.  * @type file
  34.  * @desc 物品栏背景使用的图片
  35.  * @dir img\parallaxes
  36.  
  37.  * @param 技能界面
  38.  * @type file
  39.  * @desc 技能界面背景使用的图片
  40.  * @dir img\parallaxes
  41.  
  42.  * @param 装备界面
  43.  * @type file
  44.  * @desc 装备界面背景使用的图片
  45.  * @dir img\parallaxes
  46.  
  47.  * @param 存档界面
  48.  * @type file
  49.  * @desc 存档界面背景使用的图片
  50.  * @dir img\parallaxes
  51.  
  52.  * @param 其他界面
  53.  * @type file
  54.  * @desc 其他界面背景使用的图片
  55.  * @dir img\parallaxes
  56. */
  57.  
  58.  
  59. /*~struct~list2:
  60.  
  61.  * @param 生效
  62.  * @type boolean
  63.  * @on 是
  64.  * @off 否
  65.  * @desc 否:false 是:true
  66.  * @default true
  67.  
  68.  * @param 名称
  69.  * @desc 显示在菜单中的名称
  70.  * @type text
  71.  
  72.  
  73.  * @param 命令
  74.  * @desc 英文命令
  75.  * @type text
  76. */
  77.  
  78.  
  79. var params = PluginManager.parameters("edit_menu");
  80.  
  81. Scene_MenuBase.prototype.createBackground = function() {
  82.     this._backgroundSprite=new Sprite();
  83.     var imageName;
  84.     if(this instanceof Scene_Menu){
  85.         imageName = params["主菜单"];
  86.     }else if(this instanceof Scene_Item){
  87.         imageName = params["物品栏"]
  88.     }else if(this instanceof Scene_Skill){
  89.         imageName = params["技能界面"]
  90.     }else if(this instanceof Scene_Equip){
  91.         imageName = params["装备界面"]
  92.     }else if(this instanceof Scene_Save || this instanceof  Scene_Load) {
  93.         imageName = params["存档界面"]
  94.     }else{
  95.         imageName = params["其他界面"]
  96.     }
  97.     this._backgroundSprite.bitmap=ImageManager(imageName);
  98.     this.addChild(this._backgroundSprite);
  99. };
  100.  
  101.  
  102. Window_MenuCommand.prototype.addOriginalCommands = function () {
  103.     this.addCommand(params["名称"], params["命令"],params["生效"]);
  104. };
  105.  
  106. var _Scene_Menu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
  107. Scene_Menu.prototype.createCommandWindow = function () {
  108.     _Scene_Menu_createCommandWindow.call(this);
  109.  
  110.     this._commandWindow.setHandler(params['命令'], this.commandRename.bind(this));
  111. };
  112.  
  113. Scene_Menu.prototype.commandRename = function () {
  114.     this._statusWindow.setFormationMode(false);
  115.     this._statusWindow.selectLast();
  116.     this._statusWindow.activate();
  117.     this._statusWindow.setHandler('ok',     this.rename_ok.bind(this));
  118.     this._statusWindow.setHandler('cancel', this.rename_cancel.bind(this));
  119. };
  120. Scene_Menu.prototype.rename_ok = function() {
  121.     SceneManager.push(Scene_Name);
  122.     SceneManager.prepareNextScene($gameParty.menuActor()._actorId, 10);
  123. };
  124. Scene_Menu.prototype.rename_cancel = function() {
  125.     this._statusWindow.deselect();
  126.     this._commandWindow.activate();
  127. };
  128.  
  129. Window_MenuStatus.prototype.processOk = function() {
  130.     $gameParty.setMenuActor($gameParty.members()[this.index()]);
  131.     Window_Selectable.prototype.processOk.call(this);
  132. };


回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
33253
在线时间
10503 小时
注册时间
2009-3-15
帖子
4757
4
发表于 2017-11-2 20:32:28 | 只看该作者
bloodship 发表于 2017-11-2 20:24
我想写成这样的,就不能用imagemanager了吧?
还是不该这么写,我究竟得怎么办。
/*:

字符不是要用'符号?

点评

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

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1422
在线时间
112 小时
注册时间
2011-8-17
帖子
43
5
 楼主| 发表于 2017-11-2 20:38:41 | 只看该作者
soulsaga 发表于 2017-11-2 20:32
字符不是要用'符号?

好的,我改成单引号。
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1044
在线时间
251 小时
注册时间
2016-9-2
帖子
126
6
发表于 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
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1422
在线时间
112 小时
注册时间
2011-8-17
帖子
43
7
 楼主| 发表于 2017-11-2 20:55:04 | 只看该作者
本帖最后由 bloodship 于 2017-11-2 20:57 编辑

我重新改一下
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1422
在线时间
112 小时
注册时间
2011-8-17
帖子
43
8
 楼主| 发表于 2017-11-2 21:01:49 | 只看该作者
改成这样了,没有报错,但是背景是黑色的,应该是没有选择到图
JAVASCRIPT 代码复制
  1. var params = PluginManager.parameters("edit_menu");
  2.  
  3. Scene_MenuBase.prototype.createBackground = function() {
  4.     this._backgroundSprite=new Sprite();
  5.  
  6.         ImageManager.loadParallax = function(filename, hue) {
  7.     return this.loadBitmap('img/Parallax/', filename, hue, true);
  8.      };
  9.  
  10.     var imageName;
  11.     if(this instanceof Scene_Menu){
  12.         imageName = params['主菜单'];
  13.     }else if(this instanceof Scene_Item){
  14.         imageName = params['物品栏']
  15.     }else if(this instanceof Scene_Skill){
  16.         imageName = params['技能界面']
  17.     }else if(this instanceof Scene_Equip){
  18.         imageName = params['装备界面']
  19.     }else if(this instanceof Scene_Save || this instanceof  Scene_Load) {
  20.         imageName = params['存档界面']
  21.     }else{
  22.         imageName = params['其他界面']
  23.     }
  24.     this._backgroundSprite.bitmap=ImageManager.loadParallax(imageName);
  25.     this.addChild(this._backgroundSprite);
  26. };


回复 支持 反对

使用道具 举报

Lv3.寻梦者

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

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

使用道具 举报

Lv3.寻梦者

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

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

JAVASCRIPT 代码复制
  1. /*:
  2.  * @plugindesc 主菜单管理
  3.  * @author 来自网络教程
  4.  * @help
  5.  
  6.  
  7.  * @param 背景图片设置
  8.  * @type struct<list1>[]
  9.  * @desc 可选项
  10.  * @default []
  11.  
  12.  * @param 菜单编辑
  13.  * @desc 可选项
  14.  * @type struct<list2>[]
  15.  * @default []
  16. */
  17.  
  18. /*~struct~list1:
  19.  
  20.  * @param 生效
  21.  * @type boolean
  22.  * @on 是
  23.  * @off 否
  24.  * @desc 否:false 是:true
  25.  * @default true
  26.  
  27.  * @param 主菜单
  28.  * @type file
  29.  * @desc 主菜单背景使用的图片
  30.  * @dir img\parallaxes
  31.  
  32.  * @param 物品栏
  33.  * @type file
  34.  * @desc 物品栏背景使用的图片
  35.  * @dir img\parallaxes
  36.  
  37.  * @param 技能界面
  38.  * @type file
  39.  * @desc 技能界面背景使用的图片
  40.  * @dir img\parallaxes
  41.  
  42.  * @param 装备界面
  43.  * @type file
  44.  * @desc 装备界面背景使用的图片
  45.  * @dir img\parallaxes
  46.  
  47.  * @param 存档界面
  48.  * @type file
  49.  * @desc 存档界面背景使用的图片
  50.  * @dir img\parallaxes
  51.  
  52.  * @param 其他界面
  53.  * @type file
  54.  * @desc 其他界面背景使用的图片
  55.  * @dir img\parallaxes
  56. */
  57.  
  58.  
  59. /*~struct~list2:
  60.  
  61.  * @param 生效
  62.  * @type boolean
  63.  * @on 是
  64.  * @off 否
  65.  * @desc 否:false 是:true
  66.  * @default true
  67.  
  68.  * @param 名称
  69.  * @desc 显示在菜单中的名称
  70.  * @type text
  71.  
  72.  
  73.  * @param 命令
  74.  * @desc 英文命令
  75.  * @type text
  76. */
  77.  
  78. var params = PluginManager.parameters("edit_menu");
  79.  
  80. Scene_MenuBase.prototype.createBackground = function() {
  81.     this._backgroundSprite=new Sprite();
  82.  
  83.         ImageManager.loadParallax = function(filename, hue) {
  84.     return this.loadBitmap('img/Parallax/', filename, hue, true);
  85.      };
  86.  
  87.     var imageName;
  88.     if(this instanceof Scene_Menu){
  89.         imageName = params['主菜单'];
  90.     }else if(this instanceof Scene_Item){
  91.         imageName = params['物品栏']
  92.     }else if(this instanceof Scene_Skill){
  93.         imageName = params['技能界面']
  94.     }else if(this instanceof Scene_Equip){
  95.         imageName = params['装备界面']
  96.     }else if(this instanceof Scene_Save || this instanceof  Scene_Load) {
  97.         imageName = params['存档界面']
  98.     }else{
  99.         imageName = params['其他界面']
  100.     }
  101.     this._backgroundSprite.bitmap=ImageManager.loadParallax(imageName);
  102.     this.addChild(this._backgroundSprite);
  103. };
  104.  
  105.  
  106. Window_MenuCommand.prototype.addOriginalCommands = function () {
  107.     this.addCommand(params['名称'], params['命令'],true);
  108. };
  109.  
  110. var _Scene_Menu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
  111. Scene_Menu.prototype.createCommandWindow = function () {
  112.     _Scene_Menu_createCommandWindow.call(this);
  113.  
  114.     this._commandWindow.setHandler(params['命令'], this.commandRename.bind(this));
  115. };
  116.  
  117. Scene_Menu.prototype.commandRename = function () {
  118.     this._statusWindow.setFormationMode(false);
  119.     this._statusWindow.selectLast();
  120.     this._statusWindow.activate();
  121.     this._statusWindow.setHandler('ok',     this.rename_ok.bind(this));
  122.     this._statusWindow.setHandler('cancel', this.rename_cancel.bind(this));
  123. };
  124. Scene_Menu.prototype.rename_ok = function() {
  125.     SceneManager.push(Scene_Name);
  126.     SceneManager.prepareNextScene($gameParty.menuActor()._actorId, 10);
  127. };
  128. Scene_Menu.prototype.rename_cancel = function() {
  129.     this._statusWindow.deselect();
  130.     this._commandWindow.activate();
  131. };
  132.  
  133. Window_MenuStatus.prototype.processOk = function() {
  134.     $gameParty.setMenuActor($gameParty.members()[this.index()]);
  135.     Window_Selectable.prototype.processOk.call(this);
  136. };



回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-10 08:35

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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