查看: 2132|回复: 2

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

[复制链接]
梦石
0
星屑
1005
在线时间
212 小时
注册时间
2011-11-23
回帖
76
发表于 2016-8-3 10:55:47 | 显示全部楼层 |阅读模式

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

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

×
下载好插件以后发现不会用
  1. //=============================================================================
  2. // MrTS_DarkRoomCovers.js
  3. //=============================================================================

  4. /*:
  5. * @plugindesc Hides or reveals regions.
  6. * @author Mr. Trivel
  7. *
  8. * @param Tile Size
  9. * @desc How big are map tiles? X Y
  10. * Default: 48 48
  11. * @default 48 48
  12. *
  13. * @help
  14. * --------------------------------------------------------------------------------
  15. * Terms of Use
  16. * --------------------------------------------------------------------------------
  17. * Don't remove the header or claim that you wrote this plugin.
  18. * Credit Mr. Trivel if using this plugin in your project.
  19. * Free for non-commercial projects.
  20. * For commercial use contact Mr. Trivel.
  21. * --------------------------------------------------------------------------------
  22. * Version 1.1
  23. * --------------------------------------------------------------------------------
  24. *
  25. * --------------------------------------------------------------------------------
  26. * Map Property Tags
  27. * --------------------------------------------------------------------------------
  28. *
  29. * --------------------------------------------------------------------------------
  30. *
  31. * --------------------------------------------------------------------------------
  32. * Plugin Commands
  33. * --------------------------------------------------------------------------------
  34. * RegionReveal [ID] - Reveals tiles of specific region
  35. * RegionHide [ID] - Hides tiles of specific region
  36. * RegionReset - Resets all open regions
  37. * --------------------------------------------------------------------------------
  38. *
  39. * --------------------------------------------------------------------------------
  40. * Version History
  41. * --------------------------------------------------------------------------------
  42. * 1.1 - Performance issues fixed, code cleanup
  43. * 1.0 - Release
  44. */

  45. (function() {
  46.         var parameters = PluginManager.parameters('MrTS_DarkRoomCovers');
  47.         var paramTileSize = String(parameters['Tile Size'] || "48 48").split(' ');
  48.         var tileSizeX = Number(paramTileSize[0]);
  49.         var tileSizeY = Number(paramTileSize[1]);

  50.         //--------------------------------------------------------------------------
  51.         // Game_Interpreter
  52.         //
  53.        
  54.         var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  55.         Game_Interpreter.prototype.pluginCommand = function(command, args) {
  56.                 _Game_Interpreter_pluginCommand.call(this, command, args);
  57.                 if (command.toLowerCase() === "regionreveal") {
  58.                         $gameMap.addToCurrentlyOpenRegions(Number(args[0]));
  59.                 } else if (command.toLowerCase() === "regionhide") {
  60.                         $gameMap.removeFromCurrentlyOpenRegions(Number(args[0]));
  61.                 } else if (command.toLowerCase() === "regionreset") {
  62.                         $gameMap.resetCurrentlyOpenRegions();
  63.                 }
  64.         };

  65.         //----------------------------------------------------------------------------
  66.         // Game_Map
  67.         //
  68.        
  69.         // currentlyOpenRegions
  70.         Game_Map.prototype.currentlyOpenRegions = function() {
  71.                 if (!this._openRegionIds) this._openRegionIds = [0];
  72.                 return this._openRegionIds;
  73.         };

  74.         Game_Map.prototype.addToCurrentlyOpenRegions = function(id) {
  75.                 if (!this._openRegionIds) this._openRegionIds = [0];
  76.                 if (!this._openRegionIds.contains(id)) this._openRegionIds.push(id);
  77.         };

  78.         Game_Map.prototype.removeFromCurrentlyOpenRegions = function(id) {
  79.                 if (!this._openRegionIds) return;
  80.                 this._openRegionIds.splice(this._openRegionIds.indexOf(id), 1);
  81.         };

  82.         Game_Map.prototype.resetCurrentlyOpenRegions = function() {
  83.                 this._openRegionIds = [0];
  84.         };

  85.         //----------------------------------------------------------------------------
  86.         // Scene_Map
  87.         //

  88.         var _SceneMap_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
  89.         Scene_Map.prototype.createDisplayObjects = function() {
  90.                 _SceneMap_createDisplayObjects.call(this);
  91.                 this.createDarkCover();
  92.         };

  93.         Scene_Map.prototype.createDarkCover = function() {
  94.                 this._darkCover = new Spriteset_DarkCover();
  95.                 this._spriteset.addChild(this._darkCover);
  96.         };

  97.         //--------------------------------------------------------------------------
  98.         // Spriteset_DarkCover
  99.         //
  100.         // Covers regions with dark dark darkness.
  101.        
  102.         function Spriteset_DarkCover() {
  103.                 this.initialize.apply(this, arguments);       
  104.         };
  105.        
  106.         Spriteset_DarkCover.prototype = Object.create(Sprite.prototype);
  107.         Spriteset_DarkCover.prototype.constructor = Spriteset_DarkCover;
  108.        
  109.         Spriteset_DarkCover.prototype.initialize = function() {
  110.                 Sprite.prototype.initialize.call(this);
  111.                 this.setFrame(0, 0, Graphics.width, Graphics.height);
  112.                 this._tone = [0, 0, 0, 0];
  113.                 this.opaque = true;
  114.                 this._darkCovers = [];
  115.                 this._displayX = 0;
  116.                 this._displayY = 0;
  117.                 this._regions = $gameMap.currentlyOpenRegions().clone();
  118.                 this.createDarkCovers();
  119.                 this.update();
  120.         };

  121.         Spriteset_DarkCover.prototype.createDarkCovers = function() {
  122.                 var bitmap = new Bitmap(tileSizeX, tileSizeY);
  123.                 bitmap.fillAll('#000000');
  124.                 for (var j = -1; j < Math.ceil(Graphics.boxHeight/tileSizeY)+2; j++) {
  125.                         this._darkCovers.push([]);
  126.                         for (var i = -1; i < Math.ceil(Graphics.boxWidth/tileSizeX)+2; i++) {
  127.                                 var cover = new Sprite(bitmap);
  128.                                 cover.x = i * tileSizeX;
  129.                                 cover.y = j * tileSizeY;
  130.                                 var regionId = $gameMap.regionId(i+this._displayX, j+this._displayY);
  131.                                 cover.visible = !(this._regions.contains(regionId));
  132.                                 this._darkCovers[j+1].push(cover);
  133.                                 this.addChild(cover);
  134.                         }
  135.                 }
  136.         };

  137.         Spriteset_DarkCover.prototype.update = function() {
  138.                 Sprite.prototype.update.call(this);
  139.                 this.x = (-$gameMap.displayX() + Math.floor($gameMap.displayX())) * tileSizeX;
  140.                 this.y = (-$gameMap.displayY() + Math.floor($gameMap.displayY())) * tileSizeY;
  141.                 if (Math.floor($gameMap.displayX()) !== this._displayX ||
  142.                         Math.floor($gameMap.displayY()) !== this._displayY ||
  143.                         !$gameMap.currentlyOpenRegions().equals(this._regions))
  144.                 {
  145.                         this._displayX = Math.floor($gameMap.displayX());
  146.                         this._displayY = Math.floor($gameMap.displayY());
  147.                         this._regions = $gameMap.currentlyOpenRegions().clone();
  148.                         for (var j = -1; j < Math.ceil(Graphics.boxHeight/tileSizeY)+2; j++) {
  149.                                 for (var i = -1; i < Math.ceil(Graphics.boxWidth/tileSizeX)+2; i++) {
  150.                                         var regionId = $gameMap.regionId(i+this._displayX, j+this._displayY);
  151.                                         this._darkCovers[j+1][i+1].visible = !(this._regions.contains(regionId));
  152.                                 }
  153.                         }
  154.                 }
  155.         };
  156. })();
复制代码
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 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重置所有打開的地區
回复

使用道具 举报

梦石
0
星屑
3105
在线时间
741 小时
注册时间
2015-2-28
回帖
784

开拓者

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

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部