objective c - capturing touches, storing in an array and then animating the array contents -
i new objective-c have made progress app through vast amount of information online. objective press record button, move icon representing ball across view. capture touches in array replay movement of ball animating touches stepping through coordinates in array on clicking play button.
the code testing attempting step through array , animate each set of co-ordinates in turn. last animation happens. guess whole approach might incorrect. please offer me , time.
nsmutablearray *yourcgpointsarray = [[nsmutablearray alloc] init]; [yourcgpointsarray addobject:[nsvalue valuewithcgpoint:cgpointmake(300, 001)]]; [yourcgpointsarray addobject:[nsvalue valuewithcgpoint:cgpointmake(300, 300)]]; [yourcgpointsarray addobject:[nsvalue valuewithcgpoint:cgpointmake(001, 300)]]; int i; i=0; while (i < 3) { [uiview beginanimations:nil context:nil]; [uiview setanimationduration:1]; [uiview setanimationdelay:1.0]; cgpoint point = [[yourcgpointsarray objectatindex:i] cgpointvalue]; player3.center = cgpointmake(point.x , point.y); [uiview commitanimations]; nslog (@"i array %d", i); nslog (@"cgpoint x %f", point.x); nslog (@"cgpoint y %f", point.y); = + 1; }
}
yes, approach incorrect. right now, code fires off 3 animations @ same time -- while loop won't wait 1 animation complete before starting next. instead, should start 1 animation, wait complete, start next, wait complete, , on. can using completion block each animation start next animation. take @ +animatewithduration:animations:completion:
, example. allows specify completion block animation.
Comments
Post a Comment