开发者

background with pattern texture

I tried it:

CCSprite *background = [CCSprite spriteWithSpriteFrame:frame];
background.textureRect = CGR开发者_Python百科ectMake(0, 0, calcadaWidth, winSize.height);
background.position = ccp(calcadaWidth * 0.5, winSize.height * 0.5);
ccTexParams params = {GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
[background.texture setTexParameters:&params];

It works if the texture is regular gl size such as 64x64, 128x128... My texture is 126x70, then, using this code I get some black space between repeats.


Cocos2D uses OpenGL and one of the limitiation of OpenGL is that if you want a texture to repeat, it must be a power of two texture.

The black spaces you are getting is where OpenGL has padded your texture up to the next power of two.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜