| 赞 | 58 |
| VIP | |
| 好人卡 | |
| 积分 | 12 |
| 经验 | |
| 最后登录 | 2023-5-29 |
| 在线时间 | 1017 小时 |
- 梦石
- 0
- 星屑
- 1232
- 在线时间
- 1017 小时
- 注册时间
- 2011-4-30
- 回帖
- 1464
|
发表于 2016-1-2 18:20:10
|
显示全部楼层
本帖最后由 汪汪 于 2016-1-2 18:48 编辑
于是......针对副作用,
把高层元件做出半透明遮挡物就好了,
高层元件在显示时在人物下面,
高层元件的半透明遮挡在人物的上面,
这样人物不需要半透明了.
于是饶了以又绕回来了{:2_276:}
缺点,不能控制单独的事件......
- (function() {
- Tilemap.prototype._paintTiles = function(startX, startY, x, y) {
- var tableEdgeVirtualId = 10000;
- //现在x = 开始x + x
- var mx = startX + x;
- //现在y = 开始y + y
- var my = startY + y;
- //dx = 现在x * 图块宽(48) 除 层宽(912)的余数 -- 以层宽为基础的 现在图块坐标 x
- var dx = (mx * this._tileWidth).mod(this._layerWidth);
- //dy = 现在y * 图块高(48) 除 层高(720)的余数 -- 以层宽为基础的 现在图块坐标 y
- var dy = (my * this._tileHeight).mod(this._layerHeight);
- //层x
- var lx = dx / this._tileWidth;
- //层y
- var ly = dy / this._tileHeight;
- var tileId0 = this._readMapData(mx, my, 0);
- var tileId1 = this._readMapData(mx, my, 1);
- var tileId2 = this._readMapData(mx, my, 2);
- var tileId3 = this._readMapData(mx, my, 3);
- var shadowBits = this._readMapData(mx, my, 4);
- var upperTileId1 = this._readMapData(mx, my - 1, 1);
- var lowerTiles = [];
- var upperTiles = [];
- if (this._isHigherTile(tileId0)) {
- upperTiles.push(tileId0);
- lowerTiles.push(tileId0);
- } else {
- lowerTiles.push(tileId0);
- }
- if (this._isHigherTile(tileId1)) {
- upperTiles.push(tileId1);
- lowerTiles.push(tileId1);
- } else {
- lowerTiles.push(tileId1);
- }
- lowerTiles.push(-shadowBits);
- if (this._isTableTile(upperTileId1) && !this._isTableTile(tileId1)) {
- if (!Tilemap.isShadowingTile(tileId0)) {
- lowerTiles.push(tableEdgeVirtualId + upperTileId1);
- }
- }
- if (this._isOverpassPosition(mx, my)) {
- upperTiles.push(tileId2);
- upperTiles.push(tileId3);
- lowerTiles.push(tileId3);
- lowerTiles.push(tileId2);
- } else {
- if (this._isHigherTile(tileId2)) {
- upperTiles.push(tileId2);
- lowerTiles.push(tileId2);
- } else {
- lowerTiles.push(tileId2);
- }
- if (this._isHigherTile(tileId3)) {
- upperTiles.push(tileId3);
- lowerTiles.push(tileId3);
- } else {
- lowerTiles.push(tileId3);
- }
- }
- var lastLowerTiles = this._readLastTiles(0, lx, ly);
- if (!lowerTiles.equals(lastLowerTiles) ||
- (Tilemap.isTileA1(tileId0) && this._frameUpdated)) {
- this._lowerBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight);
- for (var i = 0; i < lowerTiles.length; i++) {
- var lowerTileId = lowerTiles[i];
- if (lowerTileId < 0) {
- this._drawShadow(this._lowerBitmap, shadowBits, dx, dy);
- } else if (lowerTileId >= tableEdgeVirtualId) {
- this._drawTableEdge(this._lowerBitmap, upperTileId1, dx, dy);
- } else {
- this._drawTile(this._lowerBitmap, lowerTileId, dx, dy);
- }
- }
- this._writeLastTiles(0, lx, ly, lowerTiles);
- }
- var lastUpperTiles = this._readLastTiles(1, lx, ly);
- if (!upperTiles.equals(lastUpperTiles)) {
- this._upperBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight);
- for (var j = 0; j < upperTiles.length; j++) {
- this._drawTile(this._upperBitmap, upperTiles[j], dx, dy);
- }
- this._writeLastTiles(1, lx, ly, upperTiles);
- }
- };
- Tilemap.prototype._createLayers = function() {
- //宽 856
- var width = this._width;
- //高 664
- var height = this._height;
- //页边 20
- var margin = this._margin;
- //图块列 19 大于等于 宽/图块宽 的最小整数 +1
- var tileCols = Math.ceil(width / this._tileWidth) + 1;
- //图块行 15 大于等于 高/图块高 的最小整数 +1
- var tileRows = Math.ceil(height / this._tileHeight) + 1;
- //层宽 912
- var layerWidth = tileCols * this._tileWidth;
- //层高 720
- 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();
- //下层移动到 -20,-20
- this._lowerLayer.move(-margin, -margin, width, height);
- //下层z 为0
- this._lowerLayer.z = 0;
- //创建上层
- this._upperLayer = new Sprite();
- //上层移动到 -20,-20
- this._upperLayer.move(-margin, -margin, width, height);
- //上层z 为0
- this._upperLayer.z = 4;
- //添加4个子项精灵到层
- for (var i = 0; i < 4; i++) {
- this._lowerLayer.addChild(new Sprite(this._lowerBitmap));
- this._upperLayer.addChild(new Sprite(this._upperBitmap));
- }
- this._upperLayer.opacity=125//修改透明度在这里.目前没有添加在游戏里修改的方法,不过在 SceneManager_scene往下一级找children应该就能找到它.......我觉得.什么时候出一个children表就好看了.
- //添加下层
- this.addChild(this._lowerLayer);
- //添加上层
- this.addChild(this._upperLayer);
- };
- })();
复制代码 |
|