At first:
I’m using cocos2d for iphone. But this isn’t so important for this question.
My problem is now…I want to scale a sprite on the Y axis. I can do that with this function:
mySprite.scaleY = myFloatValue;
I want to set the scaleY value related to the rotation of the sprite..
Some cases:
If the rotation is 0, scaleY is 0.
If the rotation is 90, scaleY is 1.
If the rotation is 180 scaleY is 0
If the rotation is 360 scaleY is 0.
If the rotation is 45 scaleY is 0.5.
Some more explanation:
If my sprite is vertical the scaleY value is 1.
If my sprite is horizontal the scaleY value is 0.
And I need a forumula for this.
I got it working for the angles between 0 and 90:
mySprite.scaleY = rotation/90.0f;
From the angles between 90 and 180 teh scaleY should go from 1.0 to 0.0f
I want to make a smooth scaling..
Btw, did you understood what I want? If not I could make a video or some screenshots..
How about
mySprite.scaleY = sinf(rotation);EDIT:
To make it always positive
Where rotation is in radians
Where rotation is in degrees