setTileGIDAt (gid, posOrX, flagsOrY, flags) {
此处省略省略。。。。
let gidAndFlags = (gid | flags) >>> 0;
this._updateTileForGID(gidAndFlags, pos);
},
_updateTileForGID (gid, pos) {
if (gid !== 0 && !this._texGrids[gid]) {
return;
}
let idx = 0 | (pos.x + pos.y * this._layerSize.width);
if (idx < this._tiles.length) {
this._tiles[idx] = gid;
this._cullingDirty = true;
}
},
如上是源码。话不多说如下是正确的代码:
_updateTileForGID (gid, pos) {
let tgid= (gid&((~(0x80000000 | 0x40000000 | 0x20000000 | 0x10000000)) >>> 0))>>>0;
if (tgid!== 0 && !this._texGrids[tgid]) {
return;
}
let idx = 0 | (pos.x + pos.y * this._layerSize.width);
if (idx < this._tiles.length) {
this._tiles[idx] = gid;
this._cullingDirty = true;
}
},