| 1063 | } |
| 1064 | |
| 1065 | SpriteBatchNodeZVertex::SpriteBatchNodeZVertex() |
| 1066 | { |
| 1067 | // |
| 1068 | // This test tests z-order |
| 1069 | // If you are going to use it is better to use a 3D projection |
| 1070 | // |
| 1071 | // WARNING: |
| 1072 | // The developer is responsible for ordering its sprites according to its Z if the sprite has |
| 1073 | // transparent parts. |
| 1074 | // |
| 1075 | |
| 1076 | // |
| 1077 | // Configure shader to mimic glAlphaTest |
| 1078 | // |
| 1079 | // auto alphaTestShader = |
| 1080 | // GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); GLint |
| 1081 | // alphaValueLocation = glGetUniformLocation(alphaTestShader->getProgram(), |
| 1082 | // GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); |
| 1083 | |
| 1084 | // set alpha test value |
| 1085 | // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison |
| 1086 | // if (getGLProgram()) |
| 1087 | // { |
| 1088 | // getGLProgram()->setUniformLocationWith1f(alphaValueLocation, 0.0f); |
| 1089 | // } |
| 1090 | |
| 1091 | auto s = Director::getInstance()->getWinSize(); |
| 1092 | float step = s.width / 12; |
| 1093 | |
| 1094 | // small capacity. Testing resizing. |
| 1095 | // Don't use capacity=1 in your real game. It is expensive to resize the capacity |
| 1096 | auto batch = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 1); |
| 1097 | // camera uses the center of the image as the pivoting point |
| 1098 | batch->setContentSize(Size(s.width, s.height)); |
| 1099 | batch->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 1100 | batch->setPosition(Vec2(s.width / 2, s.height / 2)); |
| 1101 | |
| 1102 | // batch->setGLProgram(alphaTestShader); |
| 1103 | addChild(batch, 0, kTagSpriteBatchNode); |
| 1104 | |
| 1105 | for (int i = 0; i < 5; i++) |
| 1106 | { |
| 1107 | auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85 * 0, 121 * 1, 85, 121)); |
| 1108 | sprite->setPosition(Vec2((i + 1) * step, s.height / 2)); |
| 1109 | sprite->setPositionZ(10 + i * 40); |
| 1110 | batch->addChild(sprite, 0); |
| 1111 | } |
| 1112 | |
| 1113 | for (int i = 5; i < 11; i++) |
| 1114 | { |
| 1115 | auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85 * 1, 121 * 0, 85, 121)); |
| 1116 | sprite->setPosition(Vec2((i + 1) * step, s.height / 2)); |
| 1117 | sprite->setPositionZ(10 + (10 - i) * 40); |
| 1118 | batch->addChild(sprite, 0); |
| 1119 | } |
| 1120 | |
| 1121 | batch->runAction(OrbitCamera::create(10, 1, 0, 0, 360, 0, 0)); |
| 1122 | } |
nothing calls this directly
no test coverage detected