Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

CCFastTMXLayer的实现问题

$
0
0

@coco_chinese 写道:

FastTMXLayer.cpp中有个tileToNodeTransform方法,在layer的初始化方面initWithTilesetInfo中会调用,我最近要研究tilemap做地图,但是我看不懂其含义,我想问的是:对于一个FAST_TMX_ORIENTATION_ISO方向的地图_tileToNodeTransform 这个mat4类型的矩阵各分量值表示什么含义,这个矩阵有什么作用?求大神指教!在此拜谢了!

Mat4 TMXLayer::tileToNodeTransform()
{
float w = mapTileSize.width / CCCONTENT_SCALE_FACTOR();
float h = mapTileSize.height / CCCONTENT_SCALE_FACTOR();
float offY = (_layerSize.height - 1) * h;

switch(_layerOrientation)
{
    case FAST_TMX_ORIENTATION_ORTHO:
    {
        _tileToNodeTransform = Mat4
        (
            w, 0.0f, 0.0f, 0.0f,
            0.0f, -h, 0.0f, offY,
            0.0f, 0.0f, 1.0f, 0.0f,
            0.0f, 0.0, 0.0f, 1.0f
        );

        return _tileToNodeTransform;
    }
    case FAST_TMX_ORIENTATION_ISO:
    {
        float offX = (_layerSize.width - 1) * w / 2;
        _tileToNodeTransform = Mat4
        (
            w/2, -w/2, 0.0f, offX,
            -h/2, -h/2, 0.0f, offY,
            0.0f, 0.0f, 1.0f, 0.0f,
            0.0f, 0.0f, 0.0f, 1.0f
        );
        return _tileToNodeTransform;
    }
    case FAST_TMX_ORIENTATION_HEX:
    {
        _tileToNodeTransform = Mat4
        (
            h * sqrtf(0.75),    0,   0, 0,
            -h/2,      -h,      0,   offY,
            0,               0,     1,  0,
            0,               0,     0,  1
        );
        return _tileToNodeTransform;
    }
    default:
    {
        _tileToNodeTransform = Mat4::IDENTITY;
        return _tileToNodeTransform;
    }
}

}

帖子: 1

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>