Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I repeat sprite horizontally ?

I have got the code to repeat X- and Y- which is:

 bg = [CCSprite spriteWithFile:@"ipadbgpattern.png" rect:CGRectMake(0, 0, 3000, 3000)];
        bg.position = ccp(500,500);
        ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
        [bg.texture setTexParameters:&params];
        [self addChild:bg];

However, I do not know how to change the params in order for the background to repeat along the horizontal axis.

like image 355
the_critic Avatar asked Oct 07 '22 00:10

the_critic


1 Answers

There's no parameter for that. Just make sure the CGRect spans the region where you want the texture to repeat, and the texture itself must be a power of two (ie 1024x1024).

I'm guessing that maybe you're using a 1024x768 texture and then you'll see a gap between texture repeats.

like image 78
LearnCocos2D Avatar answered Oct 13 '22 07:10

LearnCocos2D