楼主: andrewx

[原创发布] 【自用·测试】图块遮挡角色半透明

[复制链接]
梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2016-1-2 19:28:49 | 显示全部楼层
本帖最后由 汪汪 于 2016-1-2 19:30 编辑
andrewx 发表于 2016-1-2 18:56
试了下发现没法跟墙壁后行走插件兼容(必然),
果然是绕回来了,一开始我也想过这么做TvT ...

点击展开/收起
  1. //=============================================================================
  2. // AndrewX - Enhanced Tile Passage
  3. // AndrewX_EnhancedTilePassage.js
  4. //=============================================================================
  5. var AndrewX = AndrewX || {};
  6. AndrewX.ETP = AndrewX.ETP || {};
  7. //=============================================================================
  8. /*:
  9. * @plugindesc v0.81 Enable characters to walk behind walls.
  10. * Also enable you to modify tile passage and priority.
  11. * @author AndrewX
  12. *
  13. * @param Wall Top Terrain Tag
  14. * @desc Tiles with this Terrain Tag will be calculated as wall top side. (Default: 7, Disable: a number greater than 7)
  15. * Use a number greater than 7 (e.g. 99) if you do not wish to make use of this property.
  16. * @default 7
  17. *
  18. * @param Wall Front Terrain Tag
  19. * @desc Tiles with this Terrain Tag will be calculated as wall front side. (Default: 6, Disable: a number greater than 7)
  20. * Use a number greater than 7 (e.g. 99) if you do not wish to make use of this property.
  21. * @default 6
  22. *
  23. * @param Default Wall Height
  24. * @desc If wall front side cannot be sampled, this will be the default wall height. (Default: 2, Disable: 0)
  25. * Use 0 if you do not wish to make use of this property.
  26. * @default 2
  27. *
  28. * @param Star Terrain Tag
  29. * @desc Tiles with this Terrain Tag will be set to star passage (above characters). (Default: 99, Disable: greater than 7)
  30. * Use a number greater than 7 (e.g. 99) if you do not wish to make use of this property.
  31. * @default 99
  32. *
  33. * @param Star Region ID List
  34. * @desc Tiles with listed Region ID will be set to star passage. Separate multiple ID with commas. (Disable: 0)
  35. * Use 0 if you do not wish to make use of this property.
  36. * @default 0
  37. *
  38. * @param Higher Tile Region ID List
  39. * @desc Tiles with listed Region ID will be shown above characters (passage unchanged). Separate with commas. (Disable: 0)
  40. * Use 0 if you do not wish to make use of this property.
  41. * @default 0
  42. *
  43. * @param Passable Tile Region ID List
  44. * @desc Tiles with listed Region ID will be always passable. Separate multiple ID with commas. (Disable: 0)
  45. * Use 0 if you do not wish to make use of this property.
  46. * @default 0
  47. *
  48. * @param Impassable Tile Region ID List
  49. * @desc Tiles with listed Region ID will not be passable. Separate multiple ID with commas. (Disable: 0)
  50. * Use 0 if you do not wish to make use of this property.
  51. * @default 0
  52. *
  53. * @help
  54. * ============================================================================
  55. * Introduction and Instructions
  56. * ============================================================================
  57. *
  58. * It's a pity multi-layered mapping is canceled since RMVX, and characters are
  59. * no longer able to walk behind walls, which makes maps a bit of weird. With
  60. * this plugin, you can set two terrain tags as wall top and wall front, and
  61. * passage behind walls are calculated automatically.
  62. *
  63. * Or you can also set a terrain tag as Star Terrain Tag, which makes tiles to be
  64. * star passage.
  65. *
  66. * Note: above tags only works for tiles in set A.
  67. *
  68. * You can also set lists of region IDs as following:
  69. * Star Region ID: Tiles with these IDs will be star passage.
  70. *
  71. * Higher Tile Region ID: Tiles with these IDs will be shown above characters,
  72. * with passage unchanged.
  73. *
  74. * Passable Tile Region ID: Tiles with these IDs will be always passable.
  75. * (layer unchanged)
  76. *
  77. * Impassable Tile Region ID: Tiles with these IDs will be not passable.
  78. *
  79. * To disable certain function, set parameter as following:
  80. * Wall Top Terrain Tag: a number greater than 7 (e.g. 99)
  81. * Wall Front Terrain Tag: a number greater than 7 (e.g. 99)
  82. * Default Wall Height: set to 0
  83. * Star Terrain Tag: a number greater than 7 (e.g. 99)
  84. * Star Region ID List: set to 0
  85. * Higher Tile Region ID List: set to 0
  86. * Passable Tile Region ID List: set to 0
  87. * Impassable Tile Region ID List: set to 0
  88. *
  89. * Note:
  90. * - 4-direction passage does not work on tiles with above tags/region id.
  91. * - Events in higher layer of wall need to be set to above characters priority
  92. *   in order to be displayed above the wall.
  93. *
  94. *
  95. * ============================================================================
  96. * Changelog
  97. * ============================================================================
  98. *
  99. * Version 0.81:
  100. * - Modified: Pulgin name changed to: Enhanced Tile Passage
  101. * - New: Passable Tile Region ID function (force tile to be passable)
  102. * - Modified: Plugin parameter description improved
  103. *
  104. * Version 0.80:
  105. * - New: Higher Tile Region ID function (force tile to be higher tile)
  106. * - New: Impassable Tile Region ID function (force tile to be impassable)
  107. * - Removed: Removed Default Wall Thickness property, which is not so useful
  108. * - Removed: To minimize side-effects on map, terrain tags only works for
  109. *                           tiles in set A now
  110. *
  111. * Version 0.71:
  112. * - Modified: Improved passage check logic
  113. * - Modified: Improved layer check logic
  114. *
  115. * Version 0.70:
  116. * - New: Can use multiple star region IDs
  117. * - Modified: Minor bug fix
  118. *
  119. * Version 0.60:
  120. * - Modified: Improved passage check logic
  121. *
  122. * Version 0.51:
  123. * - Modified: Optimized logic for passage and higher layer check
  124. * - Modified: Disabled default wall thickness by default
  125. *
  126. * Version 0.50:
  127. * - New: Star region ID can be used now
  128. * - New: Higher and lower layers of wall tile are calculated automatically now
  129. * - New: B~E tiles can be displayed above walls. So no need to modify
  130. *   additional star passage
  131. * - Modified: Rearrange the order of parameters
  132. *
  133. * Version 0.01:
  134. * - Finished prototype
  135. *
  136. * ============================================================================
  137. * Term of Use
  138. * ============================================================================
  139. *
  140. * Free for use in non-commercial or commercial RMMV projects
  141. * Please credit AndrewX
  142. *
  143. */
  144. //=============================================================================

  145. //=============================================================================
  146. // Parameter Variables
  147. //=============================================================================

  148. var parameters = PluginManager.parameters('AndrewX_EnhancedTilePassage');
  149. var starTag = Number(parameters['Star Terrain Tag']);
  150. var starId = parameters['Star Region ID List'].split(",");
  151. for (var i = 0; i < starId.length; i++) {
  152.         starId[i] = Number(starId[i]);
  153. };
  154. var higherId = parameters['Higher Tile Region ID List'].split(",");
  155. for (var i = 0; i < higherId.length; i++) {
  156.         higherId[i] = Number(higherId[i]);
  157. };
  158. var passableId = parameters['Passable Tile Region ID List'].split(",");
  159. for (var i = 0; i < higherId.length; i++) {
  160.         passableId[i] = Number(passableId[i]);
  161. };
  162. var impassableId = parameters['Impassable Tile Region ID List'].split(",");
  163. for (var i = 0; i < higherId.length; i++) {
  164.         impassableId[i] = Number(impassableId[i]);
  165. };
  166. var topTag = Number(parameters['Wall Top Terrain Tag']);
  167. var frontTag = Number(parameters['Wall Front Terrain Tag']);
  168. var defWallHeight = Number(parameters['Default Wall Height']);

  169. //=============================================================================
  170. // Private tag check for game map
  171. //=============================================================================

  172. Game_Map.prototype._hasTag = function(x, y, t) {
  173.         var flags = this.tilesetFlags();
  174.         var tiles = this.allTiles(x, y);
  175.         if (tiles[0] === 0 && tiles[1] === 0 && tiles[2] === 0 && tiles[3] === 0) {
  176.                 return false;
  177.         }
  178.         if ((flags[tiles[3]] & 0xF000) === (t << 12)) {
  179.                 return true;
  180.         }
  181.         return false;
  182. };

  183. //=============================================================================
  184. // Private passage check for upper layers
  185. //=============================================================================

  186. Game_Map.prototype._normalCheckPassage = function(x, y, bit) {
  187.         var flags = this.tilesetFlags();
  188.         var tiles = this.allTiles(x, y);
  189.         for (var i = 0; i < tiles.length - 2; i++) {
  190.                 var flag = flags[tiles[i]];
  191.                 if ((flag & 0x10) !== 0) // [*] No effect on passage
  192.                         continue;
  193.                 if ((flag & bit) === 0) // [o] Passable
  194.                         return true;
  195.                 if ((flag & bit) === bit) // [x] Impassable
  196.                         return false;
  197.         }
  198.         return false;
  199. };

  200. //=============================================================================
  201. // Modified passage check
  202. //=============================================================================

  203. AndrewX.ETP.checkPassage = Game_Map.prototype.checkPassage;
  204. Game_Map.prototype.checkPassage = function(x, y, bit) {
  205.         var flags = this.tilesetFlags();
  206.         var tiles = this.allTiles(x, y);
  207.         var mapHeight = $dataMap.height;
  208.         var upperTop = 0;
  209.         var upperFront = 0;
  210.         var lowerTop = 0;
  211.         var lowerFront = 0;
  212.         if ($gameMap.regionId(x, y) && starId.contains($gameMap.regionId(x, y))) {
  213.                 return true;
  214.         }
  215.         if ($gameMap.regionId(x, y) && passableId.contains($gameMap.regionId(x, y))) {
  216.                 return true;
  217.         }
  218.         if ($gameMap.regionId(x, y) && impassableId.contains($gameMap.regionId(x, y))) {
  219.                 return false;
  220.         }
  221.         if (!(this._hasTag(x, y, topTag) || this._hasTag(x, y, frontTag) ||
  222.                         this._hasTag(x, y, starTag))) {
  223.                 return AndrewX.ETP.checkPassage.call(this, x, y, bit);
  224.         }
  225.         if (this._hasTag(x, y, starTag)) {
  226.                 return true;
  227.         } else if (this._hasTag(x, y, frontTag)) {
  228.                 var j = 1;
  229.                 while (y + j < mapHeight && this._hasTag(x, y + j, frontTag)) {
  230.                         lowerFront++;
  231.                         j++;
  232.                 }
  233.                 j = 1;
  234.                 while (y - j >= 0 && this._hasTag(x, y - j, frontTag)) {
  235.                         upperFront++;
  236.                         j++;
  237.                 }
  238.                 while (y - j >= 0 && this._hasTag(x, y - j, topTag)) {
  239.                         upperTop++;
  240.                         j++;
  241.                 }
  242.                 if (upperTop === 0) {
  243.                         return this._normalCheckPassage(x, y, bit);
  244.                 } else if (lowerFront + 1 <= upperTop) {
  245.                         return this._normalCheckPassage(x, y, bit);
  246.                 } else {
  247.                         return true;
  248.                 }
  249.         } else if (this._hasTag(x, y, topTag)) {
  250.                 var j = 1;
  251.                 while (y - j >= 0 && this._hasTag(x, y - j, topTag)) {
  252.                         upperTop++;
  253.                         j++;
  254.                 }
  255.                 j = 1;
  256.                 while (y + j < mapHeight && this._hasTag(x, y + j, topTag)) {
  257.                         lowerTop++;
  258.                         j++;
  259.                 }
  260.                 while (y + j < mapHeight && this._hasTag(x, y + j, frontTag)) {
  261.                         lowerFront++;
  262.                         j++;
  263.                 }
  264.                 if (lowerFront === 0) {
  265.                         if (upperTop + 1 <= defWallHeight) {
  266.                                 return true;
  267.                         } else {
  268.                                 return this._normalCheckPassage(x, y, bit);
  269.                         }
  270.                 } else if (upperTop + 1 <= lowerFront) {
  271.                         return true;
  272.                 } else {
  273.                         return this._normalCheckPassage(x, y, bit);
  274.                 }
  275.         }
  276. };

  277. //=============================================================================
  278. // Private tag check for tilemap
  279. //=============================================================================

  280. Tilemap.prototype._tileHasTag = function(x, y, t) {
  281.         var tileId = this._readMapData(x, y, 0);
  282.         if ((this.flags[tileId] & 0xF000) === (t << 12)) {
  283.                 return true;
  284.         }
  285.         return false;
  286. };

  287. //=============================================================================
  288. // Private new higher tile check
  289. //=============================================================================

  290. Tilemap.prototype._isHigherTileNew = function(x, y) {
  291.         var mapHeight = this._mapHeight;
  292.         var upperTop = 0;
  293.         var upperFront = 0;
  294.         var lowerTop = 0;
  295.         var lowerFront = 0;
  296.         if ($gameMap.regionId(x, y + 1) && starId.contains($gameMap.regionId(x, y + 1))) {
  297.                 return true;
  298.         } //if lower tile is star passage
  299.         if ($gameMap.regionId(x, y) && starId.contains($gameMap.regionId(x, y))) {
  300.                 return true;
  301.         } else if ($gameMap.regionId(x, y) && higherId.contains($gameMap.regionId(x, y))) {
  302.                 return true;
  303.         } else if (this._tileHasTag(x, y, starTag)) {
  304.                 return true;
  305.         } else if (this._tileHasTag(x, y, frontTag)) {
  306.                 var i = 1;
  307.                 while (y + i < mapHeight && this._tileHasTag(x, y + i, frontTag)) {
  308.                         lowerFront++;
  309.                         i++;
  310.                 }
  311.                 i = 1;
  312.                 while (y - i >= 0 && this._tileHasTag(x, y - i, frontTag)) {
  313.                         upperFront++;
  314.                         i++;
  315.                 }
  316.                 while (y - i >= 0 && this._tileHasTag(x, y - i, topTag)) {
  317.                         upperTop++;
  318.                         i++;
  319.                 }
  320.                 if (upperTop === 0) {
  321.                         return false;
  322.                 } else if (lowerFront + 1 <= upperTop) {
  323.                         return false;
  324.                 } else {
  325.                         return true;
  326.                 }
  327.         } else if (this._tileHasTag(x, y, topTag)) {
  328.                 var i = 1;
  329.                 while (y - i >= 0 && this._tileHasTag(x, y - i, topTag)) {
  330.                         upperTop++;
  331.                         i++;
  332.                 }
  333.                 i = 1;
  334.                 while (y + i < mapHeight && this._tileHasTag(x, y + i, topTag)) {
  335.                         lowerTop++;
  336.                         i++;
  337.                 }
  338.                 while (y + i < mapHeight && this._tileHasTag(x, y + i, frontTag)) {
  339.                         lowerFront++;
  340.                         i++;
  341.                 }
  342.                 if (lowerFront === 0) {
  343.                         if (upperTop + 1 <= defWallHeight) {
  344.                                 return true;
  345.                         } else {
  346.                                 return false;
  347.                         }
  348.                 } else if (upperTop + 1 <= lowerFront) {
  349.                         return true;
  350.                 } else {
  351.                         return false;
  352.                 }
  353.         } else {
  354.                 return false;
  355.         }
  356. };

  357. //=============================================================================
  358. // Modified _paintTiles
  359. //=============================================================================

  360. AndrewX.ETP._paintTiles = Tilemap.prototype._paintTiles;
  361. Tilemap.prototype._paintTiles = function(startX, startY, x, y) {
  362.         if (($gameMap.regionId(startX + x, startY + y) &&
  363.                         starId.contains($gameMap.regionId(startX + x, startY + y))) ||
  364.                 ($gameMap.regionId(startX + x, startY + y) &&
  365.                         higherId.contains($gameMap.regionId(startX + x, startY + y))) ||
  366.                 this._tileHasTag(startX + x, startY + y, starTag) ||
  367.                 this._tileHasTag(startX + x, startY + y, topTag) ||
  368.                 this._tileHasTag(startX + x, startY + y, frontTag)) {
  369.                 var tableEdgeVirtualId = 10000;
  370.                 var mx = startX + x;
  371.                 var my = startY + y;
  372.                 var dx = (mx * this._tileWidth).mod(this._layerWidth);
  373.                 var dy = (my * this._tileHeight).mod(this._layerHeight);
  374.                 var lx = dx / this._tileWidth;
  375.                 var ly = dy / this._tileHeight;
  376.                 var tileId0 = this._readMapData(mx, my, 0);
  377.                 var tileId1 = this._readMapData(mx, my, 1);
  378.                 var tileId2 = this._readMapData(mx, my, 2);
  379.                 var tileId3 = this._readMapData(mx, my, 3);
  380.                 var shadowBits = this._readMapData(mx, my, 4);
  381.                 var upperTileId1 = this._readMapData(mx, my - 1, 1);
  382.                 var lowerTiles = [];
  383.                 var upperTiles = [];

  384.                 var isHigher = this._isHigherTileNew(mx, my);

  385.                 if (isHigher) {
  386.                         upperTiles.push(tileId0);
  387.                         lowerTiles.push(tileId0);
  388.                 } else {
  389.                         lowerTiles.push(tileId0);
  390.                 }
  391.                 if (isHigher) {
  392.                         upperTiles.push(tileId1);
  393.                         lowerTiles.push(tileId1);
  394.                 } else {
  395.                         lowerTiles.push(tileId1);
  396.                 }

  397.                 lowerTiles.push(-shadowBits);

  398.                 if (this._isTableTile(upperTileId1) && !this._isTableTile(tileId1)) {
  399.                         if (!Tilemap.isShadowingTile(tileId0)) {
  400.                                 lowerTiles.push(tableEdgeVirtualId + upperTileId1);
  401.                         }
  402.                 }

  403.                 if (this._isOverpassPosition(mx, my)) {
  404.                         upperTiles.push(tileId2);
  405.                         upperTiles.push(tileId3);
  406.                         lowerTiles.push(tileId2);
  407.                         lowerTiles.push(tileId3);
  408.                 } else {
  409.                         if (isHigher) {
  410.                                 upperTiles.push(tileId2);
  411.                                 lowerTiles.push(tileId2);
  412.                         } else {
  413.                                 lowerTiles.push(tileId2);
  414.                         }
  415.                         if (isHigher) {
  416.                                 upperTiles.push(tileId3);
  417.                                 lowerTiles.push(tileId3);
  418.                         } else {
  419.                                 lowerTiles.push(tileId3);
  420.                         }
  421.                 }

  422.                 var count = 1000 + this.animationCount - my;
  423.                 var frameUpdated = (count % 30 === 0);
  424.                 this._animationFrame = Math.floor(count / 30);

  425.                 var lastLowerTiles = this._readLastTiles(0, lx, ly);
  426.                 if (!lowerTiles.equals(lastLowerTiles) ||
  427.                         (Tilemap.isTileA1(tileId0) && frameUpdated)) {
  428.                         this._lowerBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight);
  429.                         for (var i = 0; i < lowerTiles.length; i++) {
  430.                                 var lowerTileId = lowerTiles[i];
  431.                                 if (lowerTileId < 0) {
  432.                                         this._drawShadow(this._lowerBitmap, shadowBits, dx, dy);
  433.                                 } else if (lowerTileId >= tableEdgeVirtualId) {
  434.                                         this._drawTableEdge(this._lowerBitmap, upperTileId1, dx, dy);
  435.                                 } else {
  436.                                         this._drawTile(this._lowerBitmap, lowerTileId, dx, dy);
  437.                                 }
  438.                         }
  439.                         this._writeLastTiles(0, lx, ly, lowerTiles);
  440.                 }

  441.                 var lastUpperTiles = this._readLastTiles(1, lx, ly);
  442.                 if (!upperTiles.equals(lastUpperTiles)) {
  443.                         this._upperBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight);
  444.                         for (var j = 0; j < upperTiles.length; j++) {
  445.                                 this._drawTile(this._upperBitmap, upperTiles[j], dx, dy);
  446.                         }
  447.                         this._writeLastTiles(1, lx, ly, upperTiles);
  448.                 }
  449.         } else {
  450.                 AndrewX.ETP._paintTiles.call(this, startX, startY, x, y);
  451.         }
  452. };
复制代码
忽然想到一个缺点.............人物太高的话....会很奇怪吧(话说,本来人物很高就会很奇怪好吧................我要xp)
回复

使用道具 举报

梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2016-1-2 20:17:13 | 显示全部楼层
  1. //=============================================================================
  2. // ceshi.js
  3. //=============================================================================
  4. /*:
  5. * @plugindesc 名称
  6. * @author wangwang作者信息
  7. *
  8. * @param cs
  9. * @desc 默认参数
  10. * @default 汪汪
  11. *
  12. * @help
  13. * 帮助的信息
  14. * 就像这样...........
  15. *
  16. */


  17.   
  18. (function() {


  19. })();
复制代码
回复

使用道具 举报

梦石
0
星屑
55
在线时间
388 小时
注册时间
2009-8-4
回帖
212
 楼主| 发表于 2016-1-2 20:36:42 | 显示全部楼层
汪汪 发表于 2016-1-2 19:28
点击展开/收起
忽然想到一个缺点.............人物太高的话....会很奇怪吧(话说,本来人物很高就会很奇怪好 ...

是说满两格及更高的角色会被切头吗?噫这是痛处
附带插件里面有个CP_Large_Sprite_Fix可以解决,但是用了以后帧速明显会拖慢。。。。。

点评

但是角色究竟有多高,什么情况下会被遮挡感觉也比较难把握。另外我这个插件遇到八方向行走问题更多。。。我也想要XP的地图。。。  发表于 2016-1-2 21:03
看了一下,其实可以考虑把第一种方法用上,不过设置为1 , 然后如果需要遮盖就把上面这个消失掉,这样可以避免不少计算,不过效果可能不好  发表于 2016-1-2 20:46
估计参考xp的那种把所有图块都用sprite绘制,靠z值和y值控制高下效果 会效率更低.......  发表于 2016-1-2 20:40
回复

使用道具 举报

梦石
0
星屑
15376
在线时间
2996 小时
注册时间
2008-11-23
回帖
2551

开拓者贵宾

发表于 2016-1-2 22:05:08 | 显示全部楼层
本帖最后由 死伤殆尽 于 2016-1-2 22:06 编辑

这个插件的想法好
但是楼主你有没有发现最后一张截图里,角色和宝箱的位置,跟右边的阴影位置是矛盾的?
虽然细究起来有点问题,但软件预设墙体上方是只可以往下走进一格的
再结合角色高度啊等等问题,我觉得这些需要统合起来考虑一下
I'm the bone of my Second Grade.
回复

使用道具 举报

梦石
0
星屑
55
在线时间
388 小时
注册时间
2009-8-4
回帖
212
 楼主| 发表于 2016-1-2 22:43:44 | 显示全部楼层
本帖最后由 andrewx 于 2016-1-2 22:54 编辑
死伤殆尽 发表于 2016-1-2 22:05
这个插件的想法好
但是楼主你有没有发现最后一张截图里,角色和宝箱的位置,跟右边的阴影位置是矛盾的?
虽 ...


我在墙壁同行插件里的算法是对于同一纵列连续墙壁自动元件,如果从上面数有n块顶部元素,那么从下面数n块不能通行。实际上正方体斜上方透视不也是这样的么,顶面宽度=底面宽度,允许行走的部分正好等于墙壁正面高度。

本身VX之后墙壁根本就不给通行,xp也只是墙壁往下一格,但我觉得不是很科学。

对于阴影...你可以认为是光线与地面135度夹角投影后偏移了,但是系统又画不出斜向的阴影什么的。说真的,自动阴影这个设计蠢爆了,又不智能又丑。你可以试着画一个顶面一格,正面多格的柱子,你会发现自动阴影还是那么愚蠢地产生一条。。。。
我都准备开插件全程屏蔽这东西。。。。
回复

使用道具 举报

梦石
0
星屑
55
在线时间
388 小时
注册时间
2009-8-4
回帖
212
 楼主| 发表于 2016-1-3 21:10:59 | 显示全部楼层
汪汪 发表于 2016-1-2 18:20
于是......针对副作用,
把高层元件做出半透明遮挡物就好了,
高层元件在显示时在人物下面,

在这个思路基础上想到可以不管tile的分层而是直接多创建一层upperLayer并添加对其的更新,这样似乎兼容性更好一点点

[pre lang="javascript" line="1"]Tilemap.prototype._createLayers = function() {
        var width = this._width;
        var height = this._height;
        var margin = this._margin;
        var tileCols = Math.ceil(width / this._tileWidth) + 1;
        var tileRows = Math.ceil(height / this._tileHeight) + 1;
        var layerWidth = tileCols * this._tileWidth;
        var layerHeight = tileRows * this._tileHeight;
        this._lowerBitmap = new Bitmap(layerWidth, layerHeight);
        this._upperBitmap = new Bitmap(layerWidth, layerHeight);
        this._layerWidth = layerWidth;
        this._layerHeight = layerHeight;

        /*
         * Z coordinate:
         *
         * 0 : Lower tiles
         * 1 : Lower characters
         * 3 : Normal characters
         * 4 : Upper tiles
         * 5 : Upper characters
         * 6 : Airship shadow
         * 7 : Balloon
         * 8 : Animation
         * 9 : Destination
         */

        this._lowerLayer = new Sprite();
        this._lowerLayer.move(-margin, -margin, width, height);
        this._lowerLayer.z = 0;

        this._upperLayer = new Sprite();
        this._upperLayer.move(-margin, -margin, width, height);
        this._upperLayer.z = 4;

        for (var i = 0; i < 4; i++) {
                this._lowerLayer.addChild(new Sprite(this._lowerBitmap));
                this._upperLayer.addChild(new Sprite(this._upperBitmap));
        }

        this.addChild(this._lowerLayer);
        this.addChild(this._upperLayer);

        // 更改原始upperLayer的z值为0,并添加半透明的upperLayerNew
        this._upperLayer.z = 0;
        this._upperLayerNew = new Sprite();
        this._upperLayerNew.move(-margin, -margin, width, height);
        this._upperLayerNew.z = 4;
        this._upperLayerNew.opacity = 200;
        for (var i = 0; i < 4; i++) {
                this._upperLayerNew.addChild(new Sprite(this._upperBitmap));
        }
        this.addChild(this._upperLayerNew);
};

Tilemap.prototype._updateLayerPositions = function(startX, startY) {
        var m = this._margin;
        var ox = Math.floor(this.origin.x);
        var oy = Math.floor(this.origin.y);
        var x2 = (ox - m).mod(this._layerWidth);
        var y2 = (oy - m).mod(this._layerHeight);
        var w1 = this._layerWidth - x2;
        var h1 = this._layerHeight - y2;
        var w2 = this._width - w1;
        var h2 = this._height - h1;

        for (var i = 0; i < 2; i++) {
                var children;
                if (i === 0) {
                        children = this._lowerLayer.children;
                } else {
                        children = this._upperLayer.children;
                }
                children[0].move(0, 0, w1, h1);
                children[0].setFrame(x2, y2, w1, h1);
                children[1].move(w1, 0, w2, h1);
                children[1].setFrame(0, y2, w2, h1);
                children[2].move(0, h1, w1, h2);
                children[2].setFrame(x2, 0, w1, h2);
                children[3].move(w1, h1, w2, h2);
                children[3].setFrame(0, 0, w2, h2);
        }

        // 增加对upperLayerNew的更新
        var children = this._upperLayerNew.children;
        children[0].move(0, 0, w1, h1);
        children[0].setFrame(x2, y2, w1, h1);
        children[1].move(w1, 0, w2, h1);
        children[1].setFrame(0, y2, w2, h1);
        children[2].move(0, h1, w1, h2);
        children[2].setFrame(x2, 0, w1, h2);
        children[3].move(w1, h1, w2, h2);
        children[3].setFrame(0, 0, w2, h2);
};[/pre]
回复

使用道具 举报

梦石
0
星屑
15376
在线时间
2996 小时
注册时间
2008-11-23
回帖
2551

开拓者贵宾

发表于 2016-1-3 22:21:18 | 显示全部楼层
本帖最后由 死伤殆尽 于 2016-1-3 22:23 编辑
andrewx 发表于 2016-1-2 22:43
我在墙壁同行插件里的算法是对于同一纵列连续墙壁自动元件,如果从上面数有n块顶部元素,那么从下面数n块 ...


我知道,所以我才说只能走进去一格的系统预设细想起来是有问题的
但这个预设又是为了确保默认设置下角色在被墙壁遮盖时能至少露出一个头顶
虽然VX开始的地图编辑器功能弱化导致连一格都走不进去
但自动阴影的算法也跟着这个预设走
然后这又导致了自动阴影在很多情况下违和感十分严重
而VX系的地图图层功能又无法在没有自动阴影的情况下解决地图阴影问题
因此VX Ace开始增加了阴影笔这个功能用来修改自动生成的阴影

这样解释之后不知道你能不能理解VX系地图编辑器在这方面有多混乱
如果要针对其中一点下手的话,其他牵连到的要素也要一并解决才行
屏蔽自动阴影其实没有太大必要,毕竟这方面的问题靠阴影笔也能解决就是了……
改造自动阴影的算法又不知道可行性有多少……

顺带一提RM默认地图图块素材的光线基本上预设是从左向右直射的,不需要去考虑什么斜方向阳光

总而言之还是那句话,我不是针对MV,但VX系的地图编辑器真的都是垃圾啊!
I'm the bone of my Second Grade.
回复

使用道具 举报

梦石
0
星屑
15376
在线时间
2996 小时
注册时间
2008-11-23
回帖
2551

开拓者贵宾

发表于 2016-1-3 22:28:28 | 显示全部楼层
其实细究起来第一张截图的房子阴影也有问题,然后角色应该也不止能走进去一格……
以前用XP画地图时碰到这种地方的处理我一般都被迫抛弃常识不管多高的墙后面永远设成只能走进一格
就游戏性的角度来考虑还是能接受的……

楼主加油吧,期待你想出能解决这个问题的方法
I'm the bone of my Second Grade.
回复

使用道具 举报

梦石
0
星屑
55
在线时间
388 小时
注册时间
2009-8-4
回帖
212
 楼主| 发表于 2016-1-4 10:21:37 | 显示全部楼层
本帖最后由 andrewx 于 2016-1-4 10:23 编辑
死伤殆尽 发表于 2016-1-3 22:28
其实细究起来第一张截图的房子阴影也有问题,然后角色应该也不止能走进去一格……
以前用XP画地图时碰到这 ...


对的,是不止一格,按理说墙壁多高就应该能往下几格,然而这默认地图就给房顶这个元件做了一格的星形通行,也是很奇怪。

如果用了半透明遮挡的话最后那张图尽管露不出头也是能看到角色位置,实际跑起来感觉还是可以的。

MV这次地图图块数据在同一格内做了六层,0是A类基础图块,1是A类装饰图快,2,3是B~E类图块叠加,4是阴影bit,5是区域id,而这个默认阴影bit又是编辑器自动算出来的,如果要改算法大概要对编辑器本身动刀了。另外自动阴影对于常用Shift画地图的简直是摧残啊Orz

我对V系地图编辑器都是垃圾这句话不能同意更多,这次所谓的六层地图数据依然被xp完爆。且不论自动原件没了解析窗口,当我发现v系自动元件精度从3*3变成了2*2,我真想骂这tm什么鬼。。。

点评

之前看到那个插件,不过好像当时还有bug,不知道现在如何了,回头研究下,实在不行用PS画多层远景图得了ORZ  发表于 2016-1-4 14:42
然后支持tiledmap的插件已经有了。  发表于 2016-1-4 13:09
可以考虑使用tiledmap这个软件,不过好像不能自动原件,目前要考虑的是对地图的格式转化……(其实.抛开mv就好。  发表于 2016-1-4 13:09
回复

使用道具 举报

梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2016-1-5 20:45:57 | 显示全部楼层
......对mv的地图太不熟悉了,求教几个语句
   为什么这里是 -shadowBits
    lowerTiles.push(-shadowBits);

   (this._isTableTile(upperTileId1) && !this._isTableTile(tileId1))  这个什么意思,实现什么效果?

    if (this._isTableTile(upperTileId1) && !this._isTableTile(tileId1)) {
      
        if (!Tilemap.isShadowingTile(tileId0)) {   这句又是要干啥..................
            lowerTiles.push(tableEdgeVirtualId + upperTileId1);  完全看不懂这个要做啥
        }
    }
   这是啥东西.....  
  this._isOverpassPosition

(想通过sprite实现 tilemap中....)
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部