Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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);}
share|improve this question

1 Answer 1

up vote 0 down vote accepted

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().

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.