I solved a similar problem for a loading bar some time ago, using glScissor
. Basically I extended CCSprite
with a float indicating the filled portion, and overrode visit
method like this.-
- (void) visit {
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, (loadingPercent / 100) * self.contentSize.width * CC_CONTENT_SCALE_FACTOR(), self.contentSize.height * 4);
[super visit];
glDisable(GL_SCISSOR_TEST);
}
Hope it helps.