如何在cocos2d-x中的等轴测瓷砖映射中设置vertexZ或适当的zorder/如何在cocos 2d-x的等轴测量



我在cocos2d-x中使用等距tilemap,我面临的一个问题与深度管理有关。玩家精灵没有正确地隐藏在放置在瓷砖贴图不同层上的树和房子后面。我已经将cc_vertexz=-1000应用于背景,并将自动用于房屋和环境层。我正在使用更新调用的以下方法设置vertex Z。

void HelloWorld::repositionSprite()
{
CCPoint p = playerSprite->getPosition();
p = CC_POINT_POINTS_TO_PIXELS(p);
float newZ = -(p.y+16) /16;
playerSprite->setVertexZ( newZ );

}

我还在AppDelegate类中启用了以下功能。

CCDirector::SharedDirector((->setDepthTest(true(;CCDirector::SharedDirector((->setProjection(kCCDirectorProjection2D(

但仍然无法找到合适的解决方案,请帮助我,让我知道我缺少什么。

假设平铺坐标的格式类似于(x,y(

                         (0,0)
                      (1,0) (0,1) 
                   (2,0) (1,1) (0,2)
                (3,0) (2,1) (1,2) (0,3)
        So on........
    int a= _tileCor.x + _tileCor.y;
   _playerSprite->setZorder(a);

最新更新