How to change tex coordinates in cocos

How to change tex coordinates in cocos
0.0 0


Could anybody help ? I can’t find how to change the texture coordinates in a texture. I need to scroll the texture to make an effect of moving but can’t find anything about that in cocos2dx.
Thanks in advance.


Did you mean sprite?




So ? I suppose there is no way to do it, am I right ?


setPosition() is ok ,or you can create a action.


What are you talking about ?
setPosition do set position.

Did you understand the question ?

Ok, I’ll try to explain it in OpenGL terms:

glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex2f(512.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex2f(512.0f, 256.0f);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 256.0f);

glTexCoord2f - change tex coordinates. So you could play with this params and you’ll see what effects you could reach.


I need to set change the texture coordinates too. Is there a method to do this?


@Attila - are you wanting to animate a spritesheet?


I want to get a texture scrolling effect inside a static sprite. I don’t want to move the sprite, just the texture inside it with modifying the texture coordinates. I need it for water (so the waves could move - scroll) inside a level.

I thought to subclass CCSprite and update the m_sQuad’s texCoords values to achieve this if there’s no easier method. Probably I will need to use a single texture for this instead of a sprite sheet and to set the texture clamp parameters to GL_REPEAT.

Any other ideas?


You guys figure this out yet? I’m trying to do the same thing.
I set the texture to repeat on a sprite with


now I want to scroll just the texture on the sprite while sprite stays stationary.


How about CCSprites setTextureRect function?


Adam Reed wrote:

How about CCSprites setTextureRect function?

Yup. That seems to work!