MCPcopy Create free account
hub / github.com/axmolengine/axmol / SpriteZVertex

Method SpriteZVertex

tests/cpp-tests/Source/SpriteTest/SpriteTest.cpp:975–1034  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

973}
974
975SpriteZVertex::SpriteZVertex()
976{
977 //
978 // This test tests z-order
979 // If you are going to use it is better to use a 3D projection
980 //
981 // WARNING:
982 // The developer is responsible for ordering its sprites according to its Z if the sprite has
983 // transparent parts.
984 //
985
986 //
987 // Configure shader to mimic glAlphaTest
988 //
989 // auto alphaTestShader =
990 // GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); GLint
991 // alphaValueLocation = glGetUniformLocation(alphaTestShader->getProgram(),
992 // GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
993 //
994 // // set alpha test value
995 // // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison
996 // if (getGLProgram())
997 // {
998 // getGLProgram()->setUniformLocationWith1f(alphaValueLocation, 0.0f);
999 // }
1000
1001 _dir = 1;
1002 _time = 0;
1003
1004 auto s = Director::getInstance()->getWinSize();
1005 float step = s.width / 12;
1006
1007 auto node = Node::create();
1008 // camera uses the center of the image as the pivoting point
1009 node->setContentSize(Size(s.width, s.height));
1010 node->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
1011 node->setPosition(Vec2(s.width / 2, s.height / 2));
1012
1013 addChild(node, 0);
1014
1015 for (int i = 0; i < 5; i++)
1016 {
1017 auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(85 * 0, 121 * 1, 85, 121));
1018 sprite->setPosition(Vec2((i + 1) * step, s.height / 2));
1019 sprite->setPositionZ(10 + i * 40);
1020 // sprite->setGLProgram(alphaTestShader);
1021 node->addChild(sprite, 0);
1022 }
1023
1024 for (int i = 5; i < 11; i++)
1025 {
1026 auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(85 * 1, 121 * 0, 85, 121));
1027 sprite->setPosition(Vec2((i + 1) * step, s.height / 2));
1028 sprite->setPositionZ(10 + (10 - i) * 40);
1029 // sprite->setGLProgram(alphaTestShader);
1030 node->addChild(sprite, 0);
1031 }
1032

Callers

nothing calls this directly

Calls 11

getInstanceFunction · 0.85
createFunction · 0.85
SizeFunction · 0.50
Vec2Function · 0.50
RectClass · 0.50
setContentSizeMethod · 0.45
setAnchorPointMethod · 0.45
setPositionMethod · 0.45
setPositionZMethod · 0.45
addChildMethod · 0.45
runActionMethod · 0.45

Tested by

no test coverage detected