VertexZ [3]

I have added in AppDelegate.cpp this code:
director->setDepthTest ( true );
director->setProjection ( kCCDirectorProjection2D );
and this code in init
this->setShaderProgram(CCShaderCache::sharedShaderCache()->getProgram ( kCCShader_PositionTextureColorAlphaTest ) );
In update I have added this code:
auto p = m_player->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); float newZ = -(p.y+32) /16; m_player->setVertexZ( newZ );
My tile size is 128x64
Please, help me.


forForum.png (584.2 KB)

Please, help me

@Maxym_Shustov

What’s your problem? Please clarify your problems first.

@Maxym_Shustov
I’m not clearly understand how to reproduce the problem. Can you describe the way to reproduce it more clearly?
There are many information we needed:
1. Which version of engine you are using?
2. Which classes & methods you modified?
3. How did you use TileMap?
4. Can you upload the resource files? Or reproduce the problem in project TestCpp?

As you know, we can’t reproduce the problem with the code snippet you mentioned.
So it will be much better if you can upload a demo to reproduce the problem.
Otherwise, maybe it’s also ok if you can provide more details for us to reproduce the problem.

Thanks for your feedback! And look forward your reply.

  1. Cocos2d-x 3.0beta
  2. I am have added

director->setDepthTest ( true ); director->setProjection ( cocos2d::Director::Projection::_2D );
in
bool AppDelegate::applicationDidFinishLaunching()
and
this->setShaderProgram(CCShaderCache::sharedShaderCache()->getProgram ( kCCShader_PositionTextureColorAlphaTest ) );
in bool GameLayer::init ().
In update function I am change vertexz value
auto p = m_player->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); float newZ = -(p.y+64) /32; m_player->setVertexZ( newZ );.
3. I am load tile map from .tmx file
m_map = TMXTiledMap::create ( m_level );
4. I load player from .png file
I have problem with display my player.

In attachments I load my map.

@Maxym_Shustov
Thanks for your details. I will take a try to reproduce the problem.
If the problem appear, we will solve it as soon as possible.

@Maxym_Shustov

  1. I load player from .png file

I’m not clearly understand this, the player is initialized with Sprite? Or the player is a part of tile map?

Another problem: Can you upload the image file used by tilemap & player? I can’t write my test project without them. Thank you!

@zhangbin
I am create player as Sprit::create, and from Tile map I am just take coordinate of player. It’s coordinate is in Object layer, that named Player.

@Maxym_Shustov
Hi, I have reproduced the problem. But now I’ve no idea how to solve it. So, I created a issue for it:
http://www.cocos2d-x.org/issues/4445

You can pay attention to it. We will resolve it as soon as possible.

@Maxym_Shustov
We have found the reason of the problem. You can take a look at it in the issue I mentioned before.
But now we don’t have good solutions to solve it.

There is a suggestion to avoid the problem:
Add the player into the TileMap as a tile. Then you can avoid the problem.

Sorry for the problem!

Thank you