查看: 6998|回复: 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了吧?
还是不该这么写,我究竟得怎么办。
  1. /*:
  2. * @plugindesc 主菜单管理
  3. * @author 来自网络教程
  4. * @help


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

  9. * @param 菜单编辑
  10. * @desc 可选项
  11. * @type struct<list2>[]
  12. * @default []
  13. */

  14. /*~struct~list1:

  15. * @param 生效
  16. * @type boolean
  17. * @on 是
  18. * @off 否
  19. * @desc 否:false 是:true
  20. * @default true

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

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

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

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

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

  41. * @param 其他界面
  42. * @type file
  43. * @desc 其他界面背景使用的图片
  44. * @dir img\parallaxes
  45. */


  46. /*~struct~list2:

  47. * @param 生效
  48. * @type boolean
  49. * @on 是
  50. * @off 否
  51. * @desc 否:false 是:true
  52. * @default true

  53. * @param 名称
  54. * @desc 显示在菜单中的名称
  55. * @type text


  56. * @param 命令
  57. * @desc 英文命令
  58. * @type text
  59. */


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

  61. Scene_MenuBase.prototype.createBackground = function() {
  62.     this._backgroundSprite=new Sprite();
  63.     var imageName;
  64.     if(this instanceof Scene_Menu){
  65.         imageName = params["主菜单"];
  66.     }else if(this instanceof Scene_Item){
  67.         imageName = params["物品栏"]
  68.     }else if(this instanceof Scene_Skill){
  69.         imageName = params["技能界面"]
  70.     }else if(this instanceof Scene_Equip){
  71.         imageName = params["装备界面"]
  72.     }else if(this instanceof Scene_Save || this instanceof  Scene_Load) {
  73.         imageName = params["存档界面"]
  74.     }else{
  75.         imageName = params["其他界面"]
  76.     }
  77.     this._backgroundSprite.bitmap=ImageManager(imageName);
  78.     this.addChild(this._backgroundSprite);
  79. };


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

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

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

  88. Scene_Menu.prototype.commandRename = function () {
  89.     this._statusWindow.setFormationMode(false);
  90.     this._statusWindow.selectLast();
  91.     this._statusWindow.activate();
  92.     this._statusWindow.setHandler('ok',     this.rename_ok.bind(this));
  93.     this._statusWindow.setHandler('cancel', this.rename_cancel.bind(this));
  94. };
  95. Scene_Menu.prototype.rename_ok = function() {
  96.     SceneManager.push(Scene_Name);
  97.     SceneManager.prepareNextScene($gameParty.menuActor()._actorId, 10);
  98. };
  99. Scene_Menu.prototype.rename_cancel = function() {
  100.     this._statusWindow.deselect();
  101.     this._commandWindow.activate();
  102. };

  103. Window_MenuStatus.prototype.processOk = function() {
  104.     $gameParty.setMenuActor($gameParty.members()[this.index()]);
  105.     Window_Selectable.prototype.processOk.call(this);
  106. };
复制代码


回复

使用道具 举报

梦石
0
星屑
39336
在线时间
11161 小时
注册时间
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 | 显示全部楼层
改成这样了,没有报错,但是背景是黑色的,应该是没有选择到图
  1. var params = PluginManager.parameters("edit_menu");

  2. Scene_MenuBase.prototype.createBackground = function() {
  3.     this._backgroundSprite=new Sprite();
  4.        
  5.         ImageManager.loadParallax = function(filename, hue) {
  6.     return this.loadBitmap('img/Parallax/', filename, hue, true);
  7.      };
  8.          
  9.     var imageName;
  10.     if(this instanceof Scene_Menu){
  11.         imageName = params['主菜单'];
  12.     }else if(this instanceof Scene_Item){
  13.         imageName = params['物品栏']
  14.     }else if(this instanceof Scene_Skill){
  15.         imageName = params['技能界面']
  16.     }else if(this instanceof Scene_Equip){
  17.         imageName = params['装备界面']
  18.     }else if(this instanceof Scene_Save || this instanceof  Scene_Load) {
  19.         imageName = params['存档界面']
  20.     }else{
  21.         imageName = params['其他界面']
  22.     }
  23.     this._backgroundSprite.bitmap=ImageManager.loadParallax(imageName);
  24.     this.addChild(this._backgroundSprite);
  25. };
复制代码


回复

使用道具 举报

梦石
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吧?

  1. /*:
  2. * @plugindesc 主菜单管理
  3. * @author 来自网络教程
  4. * @help


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

  9. * @param 菜单编辑
  10. * @desc 可选项
  11. * @type struct<list2>[]
  12. * @default []
  13. */

  14. /*~struct~list1:

  15. * @param 生效
  16. * @type boolean
  17. * @on 是
  18. * @off 否
  19. * @desc 否:false 是:true
  20. * @default true

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

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

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

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

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

  41. * @param 其他界面
  42. * @type file
  43. * @desc 其他界面背景使用的图片
  44. * @dir img\parallaxes
  45. */


  46. /*~struct~list2:

  47. * @param 生效
  48. * @type boolean
  49. * @on 是
  50. * @off 否
  51. * @desc 否:false 是:true
  52. * @default true

  53. * @param 名称
  54. * @desc 显示在菜单中的名称
  55. * @type text


  56. * @param 命令
  57. * @desc 英文命令
  58. * @type text
  59. */

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

  61. Scene_MenuBase.prototype.createBackground = function() {
  62.     this._backgroundSprite=new Sprite();
  63.        
  64.         ImageManager.loadParallax = function(filename, hue) {
  65.     return this.loadBitmap('img/Parallax/', filename, hue, true);
  66.      };
  67.          
  68.     var imageName;
  69.     if(this instanceof Scene_Menu){
  70.         imageName = params['主菜单'];
  71.     }else if(this instanceof Scene_Item){
  72.         imageName = params['物品栏']
  73.     }else if(this instanceof Scene_Skill){
  74.         imageName = params['技能界面']
  75.     }else if(this instanceof Scene_Equip){
  76.         imageName = params['装备界面']
  77.     }else if(this instanceof Scene_Save || this instanceof  Scene_Load) {
  78.         imageName = params['存档界面']
  79.     }else{
  80.         imageName = params['其他界面']
  81.     }
  82.     this._backgroundSprite.bitmap=ImageManager.loadParallax(imageName);
  83.     this.addChild(this._backgroundSprite);
  84. };


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

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

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

  93. Scene_Menu.prototype.commandRename = function () {
  94.     this._statusWindow.setFormationMode(false);
  95.     this._statusWindow.selectLast();
  96.     this._statusWindow.activate();
  97.     this._statusWindow.setHandler('ok',     this.rename_ok.bind(this));
  98.     this._statusWindow.setHandler('cancel', this.rename_cancel.bind(this));
  99. };
  100. Scene_Menu.prototype.rename_ok = function() {
  101.     SceneManager.push(Scene_Name);
  102.     SceneManager.prepareNextScene($gameParty.menuActor()._actorId, 10);
  103. };
  104. Scene_Menu.prototype.rename_cancel = function() {
  105.     this._statusWindow.deselect();
  106.     this._commandWindow.activate();
  107. };

  108. Window_MenuStatus.prototype.processOk = function() {
  109.     $gameParty.setMenuActor($gameParty.members()[this.index()]);
  110.     Window_Selectable.prototype.processOk.call(this);
  111. };
复制代码



回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部