在cocos2d重复背景有黑色边缘! [英] Repeating background in cocos2d has black edges!

查看:124
本文介绍了在cocos2d重复背景有黑色边缘!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的iPhone应用程式设置一个平铺/重复的背景。

I am attempting to setup a tiled/repeating background for my iPhone app.

代码工作,因为背景是重复的,似乎每个重复周围有一个黑色的边框,我不知道为什么,图像是200x200。下面是它如何与代码一起的截图:

The code "works" in that the background is repeating like it should be but I seem to have a black border around each repetition and I dont know why, the image is exactly 200x200. Here is a screenshot of how it looks along with the code:

if ((self=[super init])) {
    CCSprite * bg = [CCSprite spriteWithFile:@"pattern11.jpg" rect:CGRectMake(0, 0, 1000, 520)];
    [bg setPosition:ccp(0, 0)];
    ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
    [bg.texture setTexParameters:&params];
    [self addChild:bg z:0];
}

推荐答案

纹理应始终处于两像16,32,64,128,256,512,1024。

Textures should always be in power of two... like 16,32,64,128,256,512,1024.

尝试将图片调整为256x256或128x128。

Try resizing the image to 256x256 or 128x128.

这篇关于在cocos2d重复背景有黑色边缘!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆