Projects > cpp > Issues > Bug #4445

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

Sprite is rendered incorrect when method setVertexZ() invoked

Bug #4445 [Closed] 2014-03-19 06:41 . Updated over 9 years ago

Here is a related post from developer :

Reproduce the problem in TestCpp:
Modify the method TMXIsoVertexZ::TMXIsoVertexZ() in file TileMapTest/TileMapTest.cpp like this:

    auto map = TMXTiledMap::create("TileMaps/iso-test-vertexz.tmx");
    addChild(map, 0, kTagTileMap);

    auto s = map->getContentSize();
    map->setPosition( Point(-s.width/2,0) );
    CCLOG("ContentSize: %f, %f", s.width,s.height);

    // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
    // can use any Sprite and it will work OK.

    // @warning The code before modify (effect is ok) 
    // auto layer = map->getLayer("Trees");
    // _tamara = layer->getTileAt( Point(29,29) );
    // _tamara->retain();

    // @warning The code to reproduce the problem
    _tamara = Sprite::create(s_pathSister1);
    _tamara->setAnchorPoint(Point(0.5, 0));
    _tamara->setScale(0.5, 0.5);

    auto move = MoveBy::create(10, Point(300,250) * (1/CC_CONTENT_SCALE_FACTOR()));
    auto back = move->reverse();
    auto seq = Sequence::create(move, back,NULL);
    _tamara->runAction( RepeatForever::create(seq) );

    schedule( schedule_selector(TMXIsoVertexZ::repositionSprite));

The incorrect effect screenshot:

incorrect.jpg (191.3 kB), 2014-03-19 06:41 2014-03-20 09:14

The reason of the problem is: The using of RenderCommand::_globalOrder conflict with the DepthTest in OpenGL.

zhangxm 2014-03-24 09:23

So what's the status of this issue? 2014-03-24 10:11

I have no solution for the issue. It's related with the implementation of the new renderer.
@dabingnn know the issue, and he also doesn't know how to solve it by now.:(

zhangxm 2014-03-25 05:51

Any thought?

zhangxm 2014-03-26 03:01
  • Target version changed from 3.0-rc1 to 3.0-rc2
  • Private changed from No to Yes
ricardo 2014-03-26 15:20

why this bug was tagged as private ?

ricardo 2014-03-26 15:21

The problem is in the alpha function.
The sprite needs to use an special shader for that, and we removed the "alpha testing shader" feature from tmx, since the rendering was not good and error prone.

zhangxm 2014-03-27 02:10

Because v3.1 is private, because it is a plan, an we may adjust it.

ricardo 2014-03-27 02:17

all the plans can be changed in the future... even Firefox, Linux, Blender... all the major open source projects can change their plans in the future... but they keep their roadmap and issues open, so they can receive input from the community.

I think there is no point in making issues privates... specially for cocos2d-x.

zhangxm 2014-03-27 02:26

Changed it to public.

zhangxm 2014-04-15 08:18
  • Target version changed from 3.0-rc2 to v3.1
zhangxm 2014-05-24 13:01
  • Target version changed from v3.1 to Candidate
stevetranby 2014-06-16 14:53

I believe I am seeing this issue where an isometric tilemap is not behaving well using setPositionZ() in 3.x where we were using setVertexZ() in 2.x. From the release notes it appeared to be that setPositionZ was settings OpenGL's z coordinate, but it looks like this isn't the case and instead is just used to sort the render commands?

Is this fixed in the latest repository commit? and if not, is it planned to fix with the new tilemap renderer? 2014-10-08 02:49

Redmine issue system is closed, we are using github issue system instead.

This issue was moved to

Atom PDF

Start date:
Due date:
% Done:


Target version:Candidate