Crazy D0G
Crazy D0G

Reputation: 150

Adjust sprite bounds of the visible part of texture

Is there any way to adjust the boundaries of the visible part of the sprite? To make it easier to understand: I have a texture, such as shown at figure 1. Then I break it into pieces and fill the resulting fragments using PRKit (wood texture on figure 2 and 3). But the resulting fragments have the transparent (green color on figure 2 and 3) and when creating a sprite from the fragments they have the size of the initial texture. Is there a way to get rid of this transparency and to adjust the size of the visible part (wood texture), openGL or cocos2d-x means? example Maybe it help - draw() method from PRKit:

void PRFilledPolygon::draw() {

//CCNode::draw();

glDisableClientState(GL_COLOR_ARRAY);

// we have a pointer to vertex points so enable client state
glBindTexture(GL_TEXTURE_2D, texture->getName());

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ONE_MINUS_SRC_ALPHA);
glVertexPointer(2, GL_FLOAT, 0, areaTrianglePoints);
glTexCoordPointer(2, GL_FLOAT, 0, textureCoordinates);

glDrawArrays(GL_TRIANGLES, 0, areaTrianglePointCount);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

//Restore texture matrix and switch back to modelview matrix
glEnableClientState(GL_COLOR_ARRAY);}

Upvotes: 0

Views: 561

Answers (1)

Crazy D0G
Crazy D0G

Reputation: 150

Ok, i did this. First, i create texture from PRFilledPolygon(PRKit), use for that CCRenderTexture, after this i applied the resulting texture for new CCSprite and then i created a bounding box, using data from sites of PRKit and applied it to a sprite using setTextureRect().

Upvotes: 1

Related Questions