Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MythicFrost

macrumors 68040
Original poster
Mar 11, 2009
3,944
40
Australia
Hi,

I've got a 10x10 UIImageView, it's a projectile in a tower defence game. In my method for this, I've got code to adjust its rotation so it faces the enemy it's following, and after that, code to actually move it towards its target.

The problem is when both the transform line and the line to move the projectile aren't commented out, it... seems to be changing size all over the place and in some instances is squished so much it's not visible at all. If I disable the transform line, it doesn't rotate but moves to its target properly, and if I disable the movement line, it faces the correct direction but obviously doesn't move.

The line of code I have to adjust its rotation is:
Code:
proj.transform = CGAffineTransformMakeRotation(angle);

And the line of code for movement is:
Code:
proj.frame = CGRectMake(proj.frame.origin.x+xStep, proj.frame.origin.y+yStep, proj.frame.size.width, proj.frame.size.height);

Both work fine separately, but when both are running, it... the size of the object seems to change from 10x10 to 40x2 and then 5x30, and so on... does anyone know what I'm doing wrong here? I'd rather my projectile not look like a sideways sheet of paper... lol
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.