Question

I am using the following code to rotate a NSImageView (actually three stacked on top of each other) the rotation works fine, but the image scales up and down when it rotates. why? and how can i fix it?

- (void)UpdateRotate:(CGPoint)mouseLoc{

mouseLoc.y = mouseLoc.y - 200;

CGPoint playerMid = CGPointMake(prect.xPos, prect.yPos);

x = mouseLoc.x - playerMid.x;
y = mouseLoc.y - playerMid.y;
double priorResult = rot;
rot = atan2(y,x) * 180 / PI;

[image rotateByAngle:-priorResult];
[image rotateByAngle:rot];
[image setNeedsDisplay:YES];
[WeaponImage rotateByAngle:-priorResult];
[WeaponImage rotateByAngle:rot];
[WeaponImage setNeedsDisplay:YES];
[ShieldImage rotateByAngle:-priorResult];
[ShieldImage rotateByAngle:rot];
[ShieldImage setNeedsDisplay:YES];
}

Solved!

instead of rotating each NSImageView i just rotated the whole NSView containing all the ImageViews =D

Code:

[self setFrameCenterRotation:-priorResult];
[self setFrameCenterRotation:rot];
[self setNeedsDisplay:YES];
Was it helpful?

Solution

Perhaps call - (void)setImageScaling:(NSImageScaling)newScaling; with NSImageScaleNone to turn off scaling?

OTHER TIPS

Use:

[anImageView setFrameCenterRotation:angleInDegrees];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top