Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a UIImageView called hitBox, and another image called mainSprite. So what I want to do is when an IBAction is pressed, it will move hitBox to above mainSprite. I don't know if this is syntax but this is what I know moves things on the screen.

hitBox.center = CGPointMake(x coordinate, y coordinate);

I just want to replace x coordinate and y coordinate with something that will place it somewhere in relation mainSprite.

share|improve this question
    
is your mainsprite a sprite. –  Robin Feb 2 '12 at 5:13
    
Woeful lack of research here. –  Byte56 Apr 18 '12 at 20:45

1 Answer 1

Why not hitBox.center=mainSprite.center ?

[edit]

hitBox.center= CGPointMake(mainSprite.center.x,mainSprite.center.y+5);
share|improve this answer
    
No i mean like 5 pixels above it. Not over it. could i do hitBox.center = mainSprite.center+5 –  Will Jan 29 '12 at 13:50
    
You can't add 5 to a CGPoint, I've edited my answer to show you how you do this. –  jptsetung Jan 29 '12 at 21:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.