iphone - How to Create Multiple imageview and Get their frames for intersection.? -


i working on game.below screen shot show whole process of game. enter image description here

first of when game start,in viewdidload move red ball using nstimer top bottom.below when click on aeroplan firs missels using nstimer...first check intersection create new balls.

          if ((cgrectintersectsrect(missels.frame,ball.frame))          {           [self performselector:@selector(createball) ];           } 

when missels hit ball split 2 parts show in screen shot.here code these 2 new balls.

 -(void)createball{   imagemove1 = [[uiimageview alloc] initwithframe:cgrectmake(x,y,50 ,50)];           uiimage *imag = [uiimage imagenamed:@"ball1.png"];   [imagemove1 setimage:imag];   imagemove1.tag=i;   [self.view addsubview:imagemove1];   [ballarray addobject:imagemove1];    imagemove2 = [[uiimageview alloc] initwithframe:cgrectmake(x,y,50 ,50)];           uiimage *imag1 = [uiimage imagenamed:@"ball1.png"];   [imagemove2 setimage:imag1];   imagemove2.tag=k;   [self.view addsubview:imagemove2];   [ball1array addobject:imagemove2];   [self performselector:@selector(moveball) ];  } 

after give movement these new balls using cakeyframeanimation .here code.

-(void)moveball{  (int i=0; i<[ballarray count]; i++) {  moveimg=[ballarray objectatindex:i];  cakeyframeanimation *pathanimation = [cakeyframeanimation animationwithkeypath:@"position"];  pathanimation.calculationmode = kcaanimationpaced;  pathanimation.fillmode = kcafillmodeforwards;  pathanimation.removedoncompletion = no;  pathanimation.duration = 15.0;  pathanimation.repeatcount = 1;  cgmutablepathref curvedpath = cgpathcreatemutable();  cgpathmovetopoint(curvedpath, null, x+15, y);  cgpathaddquadcurvetopoint(curvedpath, null, 20, 10, 100, 330);  pathanimation.path = curvedpath;  cgpathrelease(curvedpath);  moveimg.center=cgpointmake(x, y);  [moveimg.layer addanimation:pathanimation forkey:@"movethesquare"];   }  (int k=0; k<[ball1array count]; k++) {         move1img=[ball1array objectatindex:k];         cakeyframeanimation *pathanimation1 = [cakeyframeanimation animationwithkeypath:@"position"];         pathanimation1.calculationmode = kcaanimationpaced;         pathanimation1.fillmode = kcafillmodeforwards;         pathanimation1.removedoncompletion = no;         pathanimation1.duration = 15.0;         pathanimation1.repeatcount = 1;         cgmutablepathref curvedpath1 = cgpathcreatemutable();         cgpathmovetopoint(curvedpath1, null, x+40, y);         cgpathaddquadcurvetopoint(curvedpath1, null, 350, 10, 380, 330);         pathanimation1.path = curvedpath1;         cgpathrelease(curvedpath1);         move1img.center=cgpointmake(x, y);         [move1img.layer addanimation:pathanimation1 forkey:@"movethesquare"];      }    } 

my methods works me create first 2 balls after missels , ball intersection.once when balls gets movement after not works intersection.so in short in games face 2 main problems.

  1. how create 2 new balls on every intersections of ball , missels.
  2. after creation of these balls how frames of these balls during movement intersection missel.just this..

      if ((cgrectintersectsrect(missels.frame,mynewballs.frame)) 

    any 1 can give best idea solve problem.any appriated.thanx in advance.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -