查看: 6167|回复: 7

[原创发布] 区域作为图层使用

[复制链接]
梦石
0
星屑
1044
在线时间
251 小时
注册时间
2016-9-2
回帖
116
发表于 2017-11-5 00:03:21 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 雪在燃 于 2017-11-5 11:59 编辑

使用区域id作为额外的图片展示,具体代码如下
  1. /*:
  2. * @plugindesc 区域图层插件
  3. * @author 雪在燃
  4. * v:1.2
  5. * @help
  6. *  区域图层插件
  7. * 使用地图备注编写<xzr_region:on>打开该功能(注,设置为任意都将打开功能,只有删除该行才会关闭功能)
  8. * 以下是一个事例
  9. * <set_regionID_1:["light",234,5]>
  10. * 代表区域1会将img/system/pictures/light展示出来,并且不透明度为234(0~255,数字越低越不透明),z坐标为5(0~10,越高则越高,降低则会被主角或npc遮盖)
  11. */

  12. (function () {
  13.     var old = Spriteset_Map.prototype.createLowerLayer;
  14.     Spriteset_Map.prototype.createLowerLayer = function () {
  15.         old.call(this);
  16.         if ($dataMap.meta.xzr_region) {
  17.             this.createShadowEx();
  18.         }
  19.     };
  20.     Spriteset_Map.prototype.createShadowEx = function () {
  21.         var data = null;//JSON.parse($dataMap.mate.set_region);
  22.         for (var x = 0; x < $gameMap.width() ; x++) {
  23.             for (var y = 0; y < $gameMap.height() ; y++) {
  24.                 var id = $gameMap.regionId(x, y);
  25.                 if (id != 0) {
  26.                     if ($dataMap.meta["set_regionID_" + id]) {
  27.                         data = JSON.parse($dataMap.meta["set_regionID_" + id]);
  28.                         var _sprite = new Sprite_Shadow(x, y, id, data);
  29.                         this._tilemap.addChild(_sprite);
  30.                     }
  31.                 }
  32.             }
  33.         }
  34.     }
  35.     function Sprite_Shadow(x, y, id) {
  36.         this.initialize.apply(this, arguments);
  37.     }
  38.     Sprite_Shadow.prototype = Object.create(Sprite.prototype);
  39.     Sprite_Shadow.prototype.constructor = Sprite_Shadow;
  40.     Sprite_Shadow.prototype.initialize = function (x, y, id,data) {
  41.         Sprite.prototype.initialize.call(this);
  42.         this.bitmap = (ImageManager.loadPicture(data[0]));
  43.         this.opacity = data[1];
  44.         this._dataZ = data[2];
  45.         this._cWidth = 0;
  46.         this._cHeight = 0;
  47.         this._realX = x;
  48.         this._realY = y;
  49.         this._isReady = false;
  50.         this.z = parseInt(id);
  51.     }
  52.     Sprite_Shadow.prototype.update = function () {
  53.         Sprite.prototype.update.call(this);
  54.         if (!this._isReady && ImageManager.isReady()) {
  55.             this._cWidth = (this.bitmap.width - 48) / 2;
  56.             this._cHeight = (this.bitmap.height - 48) / 2;
  57.             this._isReady = true;
  58.         }
  59.         this.updatePosition();
  60.     }
  61.    
  62.     Sprite_Shadow.prototype.updatePosition = function ()
  63.     {
  64.         this.z = this._dataZ;
  65.         this.x = this.screenX();
  66.         this.y = this.screenY();
  67.     }
  68.     Sprite_Shadow.prototype.scrolledX = function () {
  69.         return $gameMap.adjustX(this._realX - 0.5);
  70.     };
  71.     Sprite_Shadow.prototype.scrolledY = function () {
  72.         return $gameMap.adjustY(this._realY - 1);
  73.     };
  74.     Sprite_Shadow.prototype.screenX = function () {
  75.         var tw = $gameMap.tileWidth();
  76.         return Math.round((this.scrolledX() * tw + tw / 2)-this._cWidth);
  77.     };
  78.     Sprite_Shadow.prototype.screenY = function () {
  79.         var th = $gameMap.tileHeight();
  80.         return Math.round((this.scrolledY() * th + th)-this._cHeight);
  81.     };
  82. })();
复制代码

初衷是作为光影脚本,如今并没有素材来实现这个功能wwww
可以把图片作为图层插入到游戏里面,图片要是正方形,并且不能小于48*48,图片会以区域所在位置居中


BaiduShurufa_2017-11-4_23-57-48.png BaiduShurufa_2017-11-4_23-58-48.png

用它来实现影子是个不错的选择!光效勉勉强强应该也可以用它实现,不过需要一个圆形的渐变光图片作为素材,作为额外图层可以用来修饰地图!
对窗户用简单的光源修饰后~
BaiduShurufa_2017-11-5_11-59-42.png

评分

参与人数 2赞 +2 收起 理由
2256538860 + 1 塞糖
白嫩白嫩的 + 1 塞糖

查看全部评分

梦石
0
星屑
801
在线时间
108 小时
注册时间
2016-7-9
回帖
28
发表于 2017-11-5 09:06:52 | 显示全部楼层
好东西先收藏了。如果能使用动态图那就更好了。
回复

使用道具 举报

梦石
0
星屑
35258
在线时间
4171 小时
注册时间
2007-12-15
回帖
9490
发表于 2017-11-5 09:23:24 | 显示全部楼层
圆形渐变光?你存一下下边的看下是不是这样?这个是透明背景的png,因为是白光,应该是看不到。
01.png


回复

使用道具 举报

梦石
0
星屑
1044
在线时间
251 小时
注册时间
2016-9-2
回帖
116
 楼主| 发表于 2017-11-5 09:42:11 | 显示全部楼层
本帖最后由 雪在燃 于 2017-11-5 09:45 编辑
89444640 发表于 2017-11-5 09:23
圆形渐变光?你存一下下边的看下是不是这样?这个是透明背景的png,因为是白光,应该是看不到。

原图太大了,缩小了2个版本,然后用插件试了试 BaiduShurufa_2017-11-5_9-43-4.png 人物在图片下会受到影响(原版阴影没有该效果)
BaiduShurufa_2017-11-5_9-45-53.png


点评

似乎可以作为光点用,用ps改下颜色吧。其实好做,ps 拉圆形 羽化 填充  发表于 2017-11-5 09:49
回复

使用道具 举报

梦石
0
星屑
34511
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

发表于 2017-11-5 12:14:34 | 显示全部楼层
本帖最后由 芯☆淡茹水 于 2017-11-5 12:17 编辑

最简单的光影效果,用一张覆盖整个地图的 bitmap, 填充黑色。
然后判断光源坐标点,坐标点位置黑色 alpha 值为 0,然后往四周辐射 alpha 值递增,直到与“黑暗”地方的 alpha  值相同。高亮的地方,比如光源点附近,可以填充 白色 来调节。
当然那些 遮挡,射线 什么的,那就是高级判断。
xp vx va mv  va mz 各类型脚本/插件定制
回复

使用道具 举报

梦石
0
星屑
1899
在线时间
158 小时
注册时间
2017-12-28
回帖
117
发表于 2023-6-11 17:27:27 | 显示全部楼层
这个帖子中的代码怎么用?谁会搞,求教。我想实现的功能是,在某张地图上显示一张图片(比如一张试卷)然后玩家在图片上进行各种标记,最后给个评价。
但是普通显示的图片在人物的上方,很不和谐。如何让显示的图片在人物和npc的下方。这个帖子好像可以,但是如何一步一步搞,我盲人摸象搞了半天,都不对,望高手指点。
回复

使用道具 举报

梦石
0
星屑
1044
在线时间
251 小时
注册时间
2016-9-2
回帖
116
 楼主| 发表于 2023-11-29 11:27:44 | 显示全部楼层
jianghe006 发表于 2023-6-11 17:27
这个帖子中的代码怎么用?谁会搞,求教。我想实现的功能是,在某张地图上显示一张图片(比如一张试卷)然后 ...

项目文件夹需要有对应的图片文件,比如light,然后在对应地图使用备注
<set_regionID_1:["light",255,5]>
此时使用地图区域1,就会在区域1显示图片,并展示出来
后面的255和5调整一下,主要调整5,看看能不能出现合适的显示效果
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部