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

Project1

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

[已经过期] 话说哪位老师能帮我做一个这个插件的例子工程

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1001
在线时间
212 小时
注册时间
2011-11-23
帖子
109
跳转到指定楼层
1
发表于 2016-8-3 10:55:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
下载好插件以后发现不会用
JAVASCRIPT 代码复制下载
  1. //=============================================================================
  2. // MrTS_DarkRoomCovers.js
  3. //=============================================================================
  4.  
  5. /*:
  6. * @plugindesc Hides or reveals regions.
  7. * @author Mr. Trivel
  8. *
  9. * @param Tile Size
  10. * @desc How big are map tiles? X Y
  11. * Default: 48 48
  12. * @default 48 48
  13. *
  14. * @help
  15. * --------------------------------------------------------------------------------
  16. * Terms of Use
  17. * --------------------------------------------------------------------------------
  18. * Don't remove the header or claim that you wrote this plugin.
  19. * Credit Mr. Trivel if using this plugin in your project.
  20. * Free for non-commercial projects.
  21. * For commercial use contact Mr. Trivel.
  22. * --------------------------------------------------------------------------------
  23. * Version 1.1
  24. * --------------------------------------------------------------------------------
  25. *
  26. * --------------------------------------------------------------------------------
  27. * Map Property Tags
  28. * --------------------------------------------------------------------------------
  29. *
  30. * --------------------------------------------------------------------------------
  31. *
  32. * --------------------------------------------------------------------------------
  33. * Plugin Commands
  34. * --------------------------------------------------------------------------------
  35. * RegionReveal [ID] - Reveals tiles of specific region
  36. * RegionHide [ID] - Hides tiles of specific region
  37. * RegionReset - Resets all open regions
  38. * --------------------------------------------------------------------------------
  39. *
  40. * --------------------------------------------------------------------------------
  41. * Version History
  42. * --------------------------------------------------------------------------------
  43. * 1.1 - Performance issues fixed, code cleanup
  44. * 1.0 - Release
  45. */
  46.  
  47. (function() {
  48.         var parameters = PluginManager.parameters('MrTS_DarkRoomCovers');
  49.         var paramTileSize = String(parameters['Tile Size'] || "48 48").split(' ');
  50.         var tileSizeX = Number(paramTileSize[0]);
  51.         var tileSizeY = Number(paramTileSize[1]);
  52.  
  53.         //--------------------------------------------------------------------------
  54.         // Game_Interpreter
  55.         //
  56.  
  57.         var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  58.         Game_Interpreter.prototype.pluginCommand = function(command, args) {
  59.                 _Game_Interpreter_pluginCommand.call(this, command, args);
  60.                 if (command.toLowerCase() === "regionreveal") {
  61.                         $gameMap.addToCurrentlyOpenRegions(Number(args[0]));
  62.                 } else if (command.toLowerCase() === "regionhide") {
  63.                         $gameMap.removeFromCurrentlyOpenRegions(Number(args[0]));
  64.                 } else if (command.toLowerCase() === "regionreset") {
  65.                         $gameMap.resetCurrentlyOpenRegions();
  66.                 }
  67.         };
  68.  
  69.         //----------------------------------------------------------------------------
  70.         // Game_Map
  71.         //
  72.  
  73.         // currentlyOpenRegions
  74.         Game_Map.prototype.currentlyOpenRegions = function() {
  75.                 if (!this._openRegionIds) this._openRegionIds = [0];
  76.                 return this._openRegionIds;
  77.         };
  78.  
  79.         Game_Map.prototype.addToCurrentlyOpenRegions = function(id) {
  80.                 if (!this._openRegionIds) this._openRegionIds = [0];
  81.                 if (!this._openRegionIds.contains(id)) this._openRegionIds.push(id);
  82.         };
  83.  
  84.         Game_Map.prototype.removeFromCurrentlyOpenRegions = function(id) {
  85.                 if (!this._openRegionIds) return;
  86.                 this._openRegionIds.splice(this._openRegionIds.indexOf(id), 1);
  87.         };
  88.  
  89.         Game_Map.prototype.resetCurrentlyOpenRegions = function() {
  90.                 this._openRegionIds = [0];
  91.         };
  92.  
  93.         //----------------------------------------------------------------------------
  94.         // Scene_Map
  95.         //
  96.  
  97.         var _SceneMap_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
  98.         Scene_Map.prototype.createDisplayObjects = function() {
  99.                 _SceneMap_createDisplayObjects.call(this);
  100.                 this.createDarkCover();
  101.         };
  102.  
  103.         Scene_Map.prototype.createDarkCover = function() {
  104.                 this._darkCover = new Spriteset_DarkCover();
  105.                 this._spriteset.addChild(this._darkCover);
  106.         };
  107.  
  108.         //--------------------------------------------------------------------------
  109.         // Spriteset_DarkCover
  110.         //
  111.         // Covers regions with dark dark darkness.
  112.  
  113.         function Spriteset_DarkCover() {
  114.                 this.initialize.apply(this, arguments);       
  115.         };
  116.  
  117.         Spriteset_DarkCover.prototype = Object.create(Sprite.prototype);
  118.         Spriteset_DarkCover.prototype.constructor = Spriteset_DarkCover;
  119.  
  120.         Spriteset_DarkCover.prototype.initialize = function() {
  121.                 Sprite.prototype.initialize.call(this);
  122.                 this.setFrame(0, 0, Graphics.width, Graphics.height);
  123.                 this._tone = [0, 0, 0, 0];
  124.                 this.opaque = true;
  125.                 this._darkCovers = [];
  126.                 this._displayX = 0;
  127.                 this._displayY = 0;
  128.                 this._regions = $gameMap.currentlyOpenRegions().clone();
  129.                 this.createDarkCovers();
  130.                 this.update();
  131.         };
  132.  
  133.         Spriteset_DarkCover.prototype.createDarkCovers = function() {
  134.                 var bitmap = new Bitmap(tileSizeX, tileSizeY);
  135.                 bitmap.fillAll('#000000');
  136.                 for (var j = -1; j < Math.ceil(Graphics.boxHeight/tileSizeY)+2; j++) {
  137.                         this._darkCovers.push([]);
  138.                         for (var i = -1; i < Math.ceil(Graphics.boxWidth/tileSizeX)+2; i++) {
  139.                                 var cover = new Sprite(bitmap);
  140.                                 cover.x = i * tileSizeX;
  141.                                 cover.y = j * tileSizeY;
  142.                                 var regionId = $gameMap.regionId(i+this._displayX, j+this._displayY);
  143.                                 cover.visible = !(this._regions.contains(regionId));
  144.                                 this._darkCovers[j+1].push(cover);
  145.                                 this.addChild(cover);
  146.                         }
  147.                 }
  148.         };
  149.  
  150.         Spriteset_DarkCover.prototype.update = function() {
  151.                 Sprite.prototype.update.call(this);
  152.                 this.x = (-$gameMap.displayX() + Math.floor($gameMap.displayX())) * tileSizeX;
  153.                 this.y = (-$gameMap.displayY() + Math.floor($gameMap.displayY())) * tileSizeY;
  154.                 if (Math.floor($gameMap.displayX()) !== this._displayX ||
  155.                         Math.floor($gameMap.displayY()) !== this._displayY ||
  156.                         !$gameMap.currentlyOpenRegions().equals(this._regions))
  157.                 {
  158.                         this._displayX = Math.floor($gameMap.displayX());
  159.                         this._displayY = Math.floor($gameMap.displayY());
  160.                         this._regions = $gameMap.currentlyOpenRegions().clone();
  161.                         for (var j = -1; j < Math.ceil(Graphics.boxHeight/tileSizeY)+2; j++) {
  162.                                 for (var i = -1; i < Math.ceil(Graphics.boxWidth/tileSizeX)+2; i++) {
  163.                                         var regionId = $gameMap.regionId(i+this._displayX, j+this._displayY);
  164.                                         this._darkCovers[j+1][i+1].visible = !(this._regions.contains(regionId));
  165.                                 }
  166.                         }
  167.                 }
  168.         };
  169. })();

Lv5.捕梦者

梦石
0
星屑
21967
在线时间
8569 小时
注册时间
2011-12-31
帖子
3362
2
发表于 2016-8-3 14:13:27 | 只看该作者
* RegionReveal [ID] - Reveals tiles of specific region揭示該區域ID的瓷磚
* RegionHide [ID] - Hides tiles of specific region隱藏該區域ID的瓷磚
* RegionReset - Resets all open regions重置所有打開的地區
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (版主)

梦石
0
星屑
3085
在线时间
740 小时
注册时间
2015-2-28
帖子
816

开拓者

3
发表于 2016-8-5 23:16:10 | 只看该作者
楼上正解。
自己懂得插件的作用之后就可以自己做了。
注释也很全啊,认真看看吧。
器识为先,文艺其从。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-5 16:01

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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