Tiling texture from sprite sheet

I am trying to get a texture tiling from a sprite sheet.

I can do just fine when I load the texture by itself.

m_bg = CCSprite::create("textures/load/load_bg.png", CCRectMake(0, 0, 1024, 512));
CCSize scale;
float bgScaleX = m_screenSize.width / m_bg->boundingBox().size.width;
float bgScaleY = m_screenSize.height / m_bg->boundingBox().size.height;
m_bg->setScaleX(bgScaleX);
m_bg->setScaleY(bgScaleY);
m_bg->setPosition(CCPoint(m_screenSize.width / 2.0f, m_screenSize.height / 2.0f));
addChild(m_bg, 0);

ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
m_bg->getTexture()->setTexParameters(&params);
It tiles just as I want. But it appears I cannot do the same from a sprite sheet. Firstly, there isn’t even a function to create from a sprite frame and specify a rectangle.

If I manually set a rectangle after loading the texture via the createWithFrameName function, it gives weird results as if it’s grabbing more from the texture. Does anyone have a solution for this?

I don’t think this is possible, even at a GPU level. You will have to manually insert the quads where you wish the wrapping to occur. But don’t worry, it’s really not a performance hit to do so, although it’s a bit more of a pain. Sorry! :\

Although, if I’m wrong please correct me!

What about using a CCTMXTiledMap to do what you want? That would make it quite simple.