I have an animating sprite that is working but what if I want it to tile along my sprite? For instance if I have a character sprite that animates, I want to be able to scale the sprite 2x wide and see the character 2 times on the sprite, each would be on the same animation frame. What I have below just stretches the one copy of the animating texture, does not repeat it.
CCTexture2D *aimTexture = CCTextureCache::sharedTextureCache()->addImage("player.png");
int frameSize = aimTexture->getContentSize().height;
// manually add frames to the frame cache
CCSpriteFrame *frame0 = CCSpriteFrame::frameWithTexture( aimTexture, CCRectMake( frameSize*0, 0, frameSize, frameSize ) );
CCSpriteFrame *frame1 = CCSpriteFrame::frameWithTexture( aimTexture, CCRectMake( frameSize*1, 0, frameSize, frameSize ) );
CCSpriteFrame *frame2 = CCSpriteFrame::frameWithTexture( aimTexture, CCRectMake( frameSize*2, 0, frameSize, frameSize ) );
CCSpriteFrame *frame3 = CCSpriteFrame::frameWithTexture( aimTexture, CCRectMake( frameSize*3, 0, frameSize, frameSize ) );
// Animation using Sprite BatchNode
CCSprite* sprite = CCSprite::spriteWithSpriteFrame(frame0);
sprite->ScaleX( 2.0f );
sprite->setPosition( ccp( SCREEN_WIDTH / 2.0f, SCREEN_HEIGHT / 2.0f ) );
addChild(sprite);
// Make repeat - doesn't work?
ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
sprite->getTexture()->setTexParameters(¶ms);
// create animation
CCMutableArray *animFrames = new CCMutableArray(4);
animFrames->addObject(frame0);
animFrames->addObject(frame1);
animFrames->addObject(frame2);
animFrames->addObject(frame3);
// animate the texture
CCAnimation* animation = CCAnimation::animationWithFrames( animFrames, 0.05f );
CCAnimate* animate = CCAnimate::actionWithAnimation( animation );
CCActionInterval* repeat = CCRepeatForever::actionWithAction( animate );
sprite->runAction( repeat );
animFrames->release();