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.
@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.
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.
@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
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.