views:

16

answers:

0

i am developing a small game which has two UIImagviews..one UIImageview(Target) is moving in horizontal line and when user taps on the screen it stops animating and the other UIImagview(Arrow) starts animating towards the presrent location of that UIImagview(target) ..i am not able to calculate progamatically the frame of Target (uiimagview) when it stopped animating ?? as i need to assign the frame to the Arrow (uiimagview) so that it moves towards the target??

i did try the following code but the arrow moves on the opposite side instead of moving towards the target??

-(void)viewDidLoad

{

CGRect layerframe;
   UIImageview Target;
   UIImageview Arrow; 

}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

UITouch *touch = [touches anyObject];

CGPoint point=[touch locationInView:self.view];

if(CGRectContainsPoint(CGRectMake(5, 5, 480, 320),point)) 
{
    layerframe= Target.frame;
}

}

-(void)animateArrow
    {

  CGPoint pos = CGPointMake(-layerframe.size.width ,-layerframe.size.height );

Arrow.center = CGPointMake(Arrow.center.x+pos.x,Arrow.center.y+pos.y);
}