Repeating background in cocos2d has black edges!(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:¶ms];
[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 中的重复背景有黑边!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:cocos2d 中的重复背景有黑边!


基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01