I have a shape and texture image.. (shape.png, texture.png)
I would like to paint a shape as texture.png pattern in cocos2d. (shape size is pretty bigger than texture image. so automatically fill texture pattern in entire shape.
I trying to know the way.
Can't find..
someone have a solution to solve this problem?
sprite = [[CCSprite alloc] initWithFile:@"texture.png"];
ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
[sprite.texture setTexParameters:¶ms];
[sprite setTextureRect: CGRectMake(0.0, 0.0, w, h)];
This code repeats a texture in both the x and the y (or s, t in texture terms). The only limitation is that your texture must be a power of two (ie. 64 * 128, 128 * 128, 1024 * 1024) etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With