cocos2d-x 如何重复 NPOT 图像
cocos2d-x how to repeat a NPOT image
我想要一个背景图像 repeat-x,但不想改变图像的智慧和高度。
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCSprite* sprite = CCSprite::create("sprite.png"); // the image size is 256 * 224, so the height is non power of 2.
CCRect spriteRect = sprite->getTextureRect();
spriteRect.size.width = s.width;
pSkyBg->setTextureRect(skyRect);
ccTexParams tp = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
sprite->getTexture()->setTexParameters(&tp);
sprite->setPosition((ccp(0, s.height)));
sprite->setAnchorPoint(ccp(0, 1));
addChild(sprite, 0);
有些不对劲,谁能帮我! 谢谢!
图像的高度和宽度必须是 2 的幂。显然224不是。
它与 2 图像的幂完美配合。
这是我的代码:
CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage("purty_wood.png");
ccTexParams tp = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
texture->setTexParameters(&tp);
CCSprite *background = CCSprite::createWithTexture(texture, CCRectMake(0, 0, visibleSize.width, visibleSize.height));
background->setPosition( ccp( visibleSize.width/2, visibleSize.height/2 ) );
this->addChild(background, 1);
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 平均图像时图像损坏
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- 如何将图像传输到c++(dll)中的缓冲区,然后在c#的缓冲区中读/写
- Vulkan验证层不断在VkQueuePresentKHR()上抛出图像布局错误
- 使用FFMPEG将RGB图像序列保存到.mp4时出现问题
- 将RGB图像保存为PPM格式
- 将图像添加到资源文件夹UWP C++
- 彩色图像的卤化物处理平均值
- C++射线示踪剂ppm表示没有足够的数据来显示图像
- 重新定位图像时如何前进到下一个内存块
- 如何使用按钮更新GTK3图像以使用C++从相机捕获图片
- 为什么 BMP 图像上的 imwrite 会卡住/不返回?
- Gstreamer:每 5 秒使用多文件墨水保存图像/jpeg
- 如何使用CImg打开图像?
- 如何使用 OpenCV 解码在两个 UWP 应用之间发送的图像字节?
- cocos2d-x 如何重复 NPOT 图像