| 赞 | 4 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2019-7-31 |
| 在线时间 | 602 小时 |
- 梦石
- 0
- 星屑
- 78
- 在线时间
- 602 小时
- 注册时间
- 2012-4-20
- 回帖
- 572
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 星月铃音 于 2015-12-27 14:46 编辑
首先,@taroxd 艾特原作者。希望您对我的机械翻译不会感到反感。如果有意见的话,我会撤掉这些内容Orz。
另外,这里的程序是按照原程序直接机械翻译,我只是进行了一定的顺序修改,只用作参考。如果有啥错误我不负责。
如果使用就说明你同意我不负责这点了哦。以下是插件
插件- //=============================================================================
- // ULDS.js
- //=============================================================================
- /*:
- * @plugindesc 无限图层显示系统
- * @author Taroxd
- *
- * @param Default Path
- * @desc 默认的路径在图像存储。
- * @default parallaxes
- *
- * @param Default Z
- * @desc 精灵 Z 的默认坐标。
- * @default 0.5
- *
- * @help This plugin does not provide plugin commands.
- *
- * Map Note: <ulds> JSON </ulds>
- * "name": 图片文件名
- * "path": 图片路径 (一般是默认路径)
- * "loop": true/false
- * 图片是不是循环。
- * "hue"/"smooth": 位图属性。
- * <attribute>: 精灵的属性。
- *
- * 一些字符串会被当作一个值,按照公式解释。
- * 在公式中, 't' 是按照帧计算。
- * 's' 指 $gameSwitches.
- * 'v' 指 $gameVaribles.
- *
- * 另外,各种辅助器可以辅助性的下定义
- *
- * 如果一个字符串被属性公式使用,
- * 将会更新每一个帧。
- *
- * 另外,例如 "anchor.x"也是可以的.
- *
- *
- * 例子:
- *
- * <ulds> {
- * "name": "BlueSky",
- * "x": "this.rx(t)",
- * "y": 50,
- * "loop": true
- * } </ulds>
- *
- */
- void function() {
- var assign = Object.assign || function(target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i];
- for (var key in source) {
- target[key] = source[key];
- }
- }
- return target;
- };
- var SAFE_UPDATE_NAME = '__update_ulds__';
- var RE = /<ulds>([^]*?)<\/ulds>/ig;
- var parameters = PluginManager.parameters('ULDS');
- var DEFAULT_SETTINGS = {
- z: parseFloat(parameters['Default Z']),
- path: parameters['Default Path'],
- smooth: true
- };
- // Feel free to add your own helper.
- var Helper = {
- t: 0,
- // Converts a coordinate on the map to the corresponding coordinate on the screen.
- rx: function(x, scrollRate) {
- if (scrollRate == null) {
- scrollRate = $gameMap.tileWidth();
- }
- if (scrollRate === 0) {
- return x;
- } else {
- return $gameMap.adjustX(x / scrollRate) * scrollRate;
- }
- },
- ry: function(y, scrollRate) {
- if (scrollRate == null) {
- scrollRate = $gameMap.tileHeight();
- }
- if (scrollRate === 0) {
- return y;
- } else {
- return $gameMap.adjustY(y / scrollRate) * scrollRate;
- }
- },
- update: function() {
- ++this.t;
- for (var key in this) {
- if (key.startsWith(SAFE_UPDATE_NAME)) {
- this[key](this.t, $gameSwitches, $gameVariables);
- }
- }
- }
- };
- // NOT a class constructor
- function ULDS(settings) {
- settings = assign({}, DEFAULT_SETTINGS, settings);
- var spriteClass = settings.loop ? ULDS.TilingSprite : ULDS.Sprite;
- var bitmap = ImageManager.loadBitmap('img/' + settings.path + '/',
- settings.name, settings.hue, settings.smooth);
- var sprite = new spriteClass(bitmap);
- delete settings.path;
- delete settings.name;
- delete settings.loop;
- delete settings.hue;
- delete settings.smooth;
- for (var key in settings) {
- var value = settings[key];
- if (typeof(value) === 'string') {
- // this.x = (formula)
- var code = "this." + key + "=(" + value + ")";
- sprite[SAFE_UPDATE_NAME + key] = new Function("t", "s", "v", code);
- } else {
- sprite[key] = value;
- }
- }
- return sprite;
- }
- ULDS.Sprite = function(bitmap) {
- Sprite.call(this, bitmap);
- };
- ULDS.Sprite.prototype = Object.create(Sprite.prototype);
- ULDS.Sprite.prototype.constructor = ULDS.Sprite;
- assign(ULDS.Sprite.prototype, Helper);
- ULDS.TilingSprite = function(bitmap) {
- TilingSprite.call(this, bitmap);
- bitmap.addLoadListener(function() {
- this.move(0, 0, bitmap.width, bitmap.height);
- }.bind(this));
- };
- ULDS.TilingSprite.prototype = Object.create(TilingSprite.prototype);
- ULDS.TilingSprite.prototype.constructor = ULDS.TilingSprite;
- assign(ULDS.TilingSprite.prototype, Helper);
- Object.defineProperties(ULDS.TilingSprite.prototype, {
- x: {
- get: function() { return -this.origin.x; },
- set: function(x) { this.origin.x = -x; }
- },
- y: {
- get: function() { return -this.origin.y; },
- set: function(y) { this.origin.y = -y; }
- }
- });
- var ct = Spriteset_Map.prototype.createTilemap;
- Spriteset_Map.prototype.createTilemap = function() {
- ct.call(this);
- var match;
- while ((match = RE.exec($dataMap.note)) !== null) {
- var settings = null;
- try {
- settings = JSON.parse(match[1]);
- } catch (e) {
- console.error(e);
- console.log(match[1]);
- }
- if (settings !== null) {
- this._tilemap.addChild(ULDS(settings));
- }
- }
- };
- }();
复制代码
已经在程序里测试,至少能显示中文没啥问题了。。 |
评分
-
查看全部评分
|