I want a background image repeat-x, but do not want to change the image's witdh and height.
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);
there is some wrong. who can help me! thanks!
The image's height and width must be power of 2. Obviously 224 is not.