查看: 2083|回复: 2

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

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

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

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

×
下载好插件以后发现不会用[pre lang="javascript" file="MrTS_DarkRoomCovers.js"]//=============================================================================
// MrTS_DarkRoomCovers.js
//=============================================================================

/*:
* @plugindesc Hides or reveals regions.
* @author Mr. Trivel
*
* @param Tile Size
* @desc How big are map tiles? X Y
* Default: 48 48
* @default 48 48
*
* @help
* --------------------------------------------------------------------------------
* Terms of Use
* --------------------------------------------------------------------------------
* Don't remove the header or claim that you wrote this plugin.
* Credit Mr. Trivel if using this plugin in your project.
* Free for non-commercial projects.
* For commercial use contact Mr. Trivel.
* --------------------------------------------------------------------------------
* Version 1.1
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Map Property Tags
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Plugin Commands
* --------------------------------------------------------------------------------
* RegionReveal [ID] - Reveals tiles of specific region
* RegionHide [ID] - Hides tiles of specific region
* RegionReset - Resets all open regions
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.1 - Performance issues fixed, code cleanup
* 1.0 - Release
*/

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

        //--------------------------------------------------------------------------
        // Game_Interpreter
        //
       
        var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
        Game_Interpreter.prototype.pluginCommand = function(command, args) {
                _Game_Interpreter_pluginCommand.call(this, command, args);
                if (command.toLowerCase() === "regionreveal") {
                        $gameMap.addToCurrentlyOpenRegions(Number(args[0]));
                } else if (command.toLowerCase() === "regionhide") {
                        $gameMap.removeFromCurrentlyOpenRegions(Number(args[0]));
                } else if (command.toLowerCase() === "regionreset") {
                        $gameMap.resetCurrentlyOpenRegions();
                }
        };

        //----------------------------------------------------------------------------
        // Game_Map
        //
       
        // currentlyOpenRegions
        Game_Map.prototype.currentlyOpenRegions = function() {
                if (!this._openRegionIds) this._openRegionIds = [0];
                return this._openRegionIds;
        };

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

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

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

        //----------------------------------------------------------------------------
        // Scene_Map
        //

        var _SceneMap_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
        Scene_Map.prototype.createDisplayObjects = function() {
                _SceneMap_createDisplayObjects.call(this);
                this.createDarkCover();
        };

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

        //--------------------------------------------------------------------------
        // Spriteset_DarkCover
        //
        // Covers regions with dark dark darkness.
       
        function Spriteset_DarkCover() {
                this.initialize.apply(this, arguments);       
        };
       
        Spriteset_DarkCover.prototype = Object.create(Sprite.prototype);
        Spriteset_DarkCover.prototype.constructor = Spriteset_DarkCover;
       
        Spriteset_DarkCover.prototype.initialize = function() {
                Sprite.prototype.initialize.call(this);
                this.setFrame(0, 0, Graphics.width, Graphics.height);
                this._tone = [0, 0, 0, 0];
                this.opaque = true;
                this._darkCovers = [];
                this._displayX = 0;
                this._displayY = 0;
                this._regions = $gameMap.currentlyOpenRegions().clone();
                this.createDarkCovers();
                this.update();
        };

        Spriteset_DarkCover.prototype.createDarkCovers = function() {
                var bitmap = new Bitmap(tileSizeX, tileSizeY);
                bitmap.fillAll('#000000');
                for (var j = -1; j < Math.ceil(Graphics.boxHeight/tileSizeY)+2; j++) {
                        this._darkCovers.push([]);
                        for (var i = -1; i < Math.ceil(Graphics.boxWidth/tileSizeX)+2; i++) {
                                var cover = new Sprite(bitmap);
                                cover.x = i * tileSizeX;
                                cover.y = j * tileSizeY;
                                var regionId = $gameMap.regionId(i+this._displayX, j+this._displayY);
                                cover.visible = !(this._regions.contains(regionId));
                                this._darkCovers[j+1].push(cover);
                                this.addChild(cover);
                        }
                }
        };

        Spriteset_DarkCover.prototype.update = function() {
                Sprite.prototype.update.call(this);
                this.x = (-$gameMap.displayX() + Math.floor($gameMap.displayX())) * tileSizeX;
                this.y = (-$gameMap.displayY() + Math.floor($gameMap.displayY())) * tileSizeY;
                if (Math.floor($gameMap.displayX()) !== this._displayX ||
                        Math.floor($gameMap.displayY()) !== this._displayY ||
                        !$gameMap.currentlyOpenRegions().equals(this._regions))
                {
                        this._displayX = Math.floor($gameMap.displayX());
                        this._displayY = Math.floor($gameMap.displayY());
                        this._regions = $gameMap.currentlyOpenRegions().clone();
                        for (var j = -1; j < Math.ceil(Graphics.boxHeight/tileSizeY)+2; j++) {
                                for (var i = -1; i < Math.ceil(Graphics.boxWidth/tileSizeX)+2; i++) {
                                        var regionId = $gameMap.regionId(i+this._displayX, j+this._displayY);
                                        this._darkCovers[j+1][i+1].visible = !(this._regions.contains(regionId));
                                }
                        }
                }
        };
})();[/pre]
梦石
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.

在本版发帖返回顶部