【求助】TiledMap实现无尽模式方案

CCC制作的2d跑酷,地图使用TiledMap制作。
有需求需要实现无尽模式。

1、CCC中,TiledMap的解析是没有接口暴露的。
2、TiledMap作为一个Node,一个tmx文件对应一个Node。在TiledMap中解析后,自动生成子Layer。

当前的想法是:
解析时,修改tmx数据。把修改后的tmx数据插入旧的tmx中。
但这个方案
1、对底层修改过多,不利于后期CCC升级维护。
2、之前预想方案,不一定可以实现。

求助下大家,是否有更好的实现方式。

有进展了吗?

我现在的需求不光是无尽地图, 还要动态加载tileset, 看来不魔改源码不行了.而且官方竟然连触摸坐标获取tiledtile的api都没给…

自己转换

在引擎源码里看到了这个内置函数

    _positionToRowCol (x, y, result) {
            const TiledMap = cc.TiledMap;
            const Orientation = TiledMap.Orientation;
            const StaggerAxis = TiledMap.StaggerAxis;

            let maptw = this._mapTileSize.width,
                mapth = this._mapTileSize.height,
                maptw2 = maptw * 0.5,
                mapth2 = mapth * 0.5;
            let row = 0, col = 0, diffX2 = 0, diffY2 = 0, axis = this._staggerAxis;
            let cols = this._layerSize.width;

            switch (this._layerOrientation) {
                // left top to right dowm
                case Orientation.ORTHO:
                    col = Math.floor(x / maptw);
                    row = Math.floor(y / mapth);
                    break;
                // right top to left down
                // iso can be treat as special hex whose hex side length is 0
                case Orientation.ISO:
                    col = Math.floor(x / maptw2);
                    row = Math.floor(y / mapth2);
                    break;
                // left top to right dowm
                case Orientation.HEX:
                    if (axis === StaggerAxis.STAGGERAXIS_Y) {
                        row = Math.floor(y / (mapth - this._diffY1));
                        diffX2 = row % 2 === 1 ? maptw2 * this._odd_even : 0;
                        col = Math.floor((x - diffX2) / maptw);
                    } else {
                        col = Math.floor(x / (maptw - this._diffX1));
                        diffY2 = col % 2 === 1 ? mapth2 * -this._odd_even : 0;
                        row = Math.floor((y - diffY2) / mapth);
                    }
                    break;
            }
            result.row = row;
            result.col = col;
            return result;
        },

666能用吗

好像是私有函数,为了实现其他功能的,自己转换一下也还好,封装一下,我就是自己转化的

数学不行啊, 不知道怎么算45度这个仿射变换