It feels simple really. I have an UIImageView:

start

and I want to apply an affine transform to get this image:

end

However, the particular transform in question eludes me. Rotating by 180° gets me this:

transform = CGAffineTransformMakeRotation(M_PI);
// similarly, CGAffineTransformMakeScale(-1, -1);

rotate

which is oviously quite far off. Translation is also problematic:

transform = CGAffineTransformMakeTranslation(x, y);

translate

Reflecting over the line y = x and then rotating 180° gets me this:

transform = CGAffineTransformMake(0, 1, 1, 0, 0, 0);
transform = CGAffineTransformRotate(M_PI);

reflect-rotate

which is closer, but still not there. Is there something obvious that I'm missing, or is this really complicated? Does anyone know what sort of transform I'm looking for here?

Edit:

Twitter feedback is suggesting that affine transforms aren't the way to go. At the end of the day, I simply want the resultant image, so any suggested routes to success are greatly appreciated!

有帮助吗?

解决方案

You are trying to move a sprite, whether you realize it or not. No transformation can move the star and keep the background. Your options are to: - make a large background and clip it at the end, so that translation works - make a sprite image on top of a separate background image. If you're using iOS7, you may want to use the Sprite Kit.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top