If I have an instance of CCTexture2D, is it not possible to modify it? Like, say, rotate it?
I know I can simply rotate the CCSprite I have. But really, I am curious about only rotating the texture affecting all the CCSprites that refer to it.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
CCTexture2D is immutable, it can not be modified at runtime.
For this reason someone created a CCMutableTexture2D class, which I used in this example project. Problem is of course that in order to rotate the texture, you would have to apply your own rotation algorithm to rotate individual pixels. That in return would require you to resize the texture to fit an arbitrarily rotated texture without cutting off the edges.
To better understand this, take a piece of paper and lay it flat in front of you. Now lay another piece of paper on top and start rotating it. You’ll notice that the rotated paper doesn’t fit in the same rectangle as the unrotated paper does.
Long story short, it’s probably going to be overkill for what you want to do. Rotating sprites is much easier and computationally rather inexpensive compared to shifting thousands of pixels around in memory, then re-binding the texture to OpenGL.