Question

I was wondering how I should repeat a texture in Cocos2d 3. I have a background and I want to “tile” it across the screen. I have found this which is using ccTexParams with GL_REPEAT but those have been made private in version 3 of cocos.

I have found another solution which can be found here it creates a loop and positions a new child node based on the size of the texture and the size you want. But is that performant? Because when you have a 1px wide background texture and want to repeat that on a iPad retina, you have more than 2000 child nodes.

What is the best way to repeat a texture.

Was it helpful?

Solution

Well since there was no method for repeating without having a POT texture I made something of my own which takes care of it.

Might be useful for someone who has this same question. The code can be found here on Github.

OTHER TIPS

CCTexture2D class has setTexParameters: method to set repeat mode. Also pay attention that the texture must have power-of-two width and height, otherwise repeating mode will be disabled.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top