我用Ray Wenderlich课程创建了动态地形,但我遇到了一些问题。我使用CCTexture2D来填充地形区域。在第一分钟它完全没问题,但经过一段时间后,质地会更顺畅,更顺畅,更顺畅。 这是代码:
纹理初始化:
ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_CLAMP_TO_EDGE};
[texturePattern.texture setTexParameters:¶ms];
justTexture = [[CCTextureCache sharedTextureCache] addImage:@"text1.jpg"];
[justTexture generateMipmap];
[justTexture setTexParameters:¶ms];
我填充区域的方法:
- (无效)画画 {
CC_NODE_DRAW_SETUP();
//ccGLBindTexture2D(texturePattern.texture.name);
ccGLBindTexture2D(justTexture.name);
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords);
ccDrawColor4F(1.0f, 1.0f, 1.0f, 1.0f);
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _hillVertices);
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, _hillTexCoords);
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nHillVertices);
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _highVertices);
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, _highTexCoords);
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nHighVertices);
}