Hello!
Could you help me with the following task?
I have created the texture as
self.texture = [[TextureMgr sharedTextureMgr] addImage: @"rock.png"];
Now I have problem that - How to transform the texture?
Regards,
Pravin
A fast, easy to use, free, and community supported 2D game engine
Hello!
Could you help me with the following task?
I have created the texture as
self.texture = [[TextureMgr sharedTextureMgr] addImage: @"rock.png"];
Now I have problem that - How to transform the texture?
Regards,
Pravin
What do you mean transform?
From what I understand in openGL, you would play around with the uv coordinates when you're applying to texture to a face to "transform" it.
Thanks for reply.
Transform means rotating object in 0 to 360 degrees.
In cocos2d the texture is created in openGL and I don't know about uv coordinates.
How to rotate the texture in 0 to 360 degrees.
Don't rotate the texture, rotate the sprite that shows it.. Would it work for you?
Thanks for reply.
I rotate the AtlasSprite instance as fallows.
enemySprite.rotation = angle;
where angle is 0 to 360;
But It's not working
It was 0 and you set it as 360?
Yes. 0 to 360 with increment of 1 degree.
to do motion like staring wheel.
i.e. make rotation along it's axis it self.
ok I see. It should work.. can you post your code here?
If you post the code it will be so much clearer. FYI you cant just do a for loop from 0 to 360 and rotate a sprite bc you wont see the updates. Also if you want something to rotate over time consider using a RotateTo or RotateBy action.
Ok.
here is my code
-(void) updateFlyingFrames: (ccTime) dt
{
displayFrame ++ ;
displayFrame = displayFrame%6 ;
[enemySprite setDisplayFrame:@"fly" index: displayFrame ];
static int angle;
angle = angle%360 ;
switch (angle) {
case 0:
angle=0;
break;
}
angle++;
enemySprite.rotation = angle ;
}
I called updateFlyingFrames fuction after 0.1 iterval as
[self schedule:@selector(updateFlyingFrames:) interval:0.1f] ;
Here enemySprite is instance of AtlasSprite.
I didn't get How to apply function RotateTo or RotateBy to AtlasSprite.
"I didn't get How to apply function RotateTo or RotateBy to AtlasSprite."
Look in the SpritesTest demo in the SpriteRotate class
id actionTo = [RotateTo actionWithDuration: 2 angle:45];
id actionBy = [RotateBy actionWithDuration:2 angle: 360];
[tamara runAction: actionTo];
[grossini runAction: actionBy];Actually , I am new to cocos2d framework.
It works great. Thanks for the follow up.
patrickC: i want to know how to transform the uv coordinates to a portion of texture? eg i want to apply liquify effect to a portion of an image? or create a pinch effect to the face???
how can i access the texture of a Sprite? how will i do the this: take a face photo, touch the nose part and that nose should glow like Lens effect?
You must log in to post.