ios - Objective-C Animating a character -


for starters trying animate main character of game can later replace images in array sprites -

ive done in header file main character :

- (void)animate; 

and in implementation file ive written :

-(void) animate{      uiimage* img1 = [uiimage imagenamed:@"obstacle.png"];     uiimage* img2 = [uiimage imagenamed:@"obstacle02.png"];     uiimage* img3 = [uiimage imagenamed:@"obstacle03.png"];     uiimage* img4 = [uiimage imagenamed:@"obstacle04.png"];      nsarray *images = [nsarray arraywithobjects:img1,img2,img3,img4, nil];     uiimageview* imageview = [[uiimageview alloc] initwithframe:cgrectmake(0.0, 0.0, 160.0, 160.0)];     //images.name = @"animation";      [imageview setanimationimages:images];     [imageview setanimationrepeatcount:0];     [imageview setanimationduration:0.5];     //imageview.center = character.center ;     [imageview startanimating];      // character used myview     // images inside array ! } 

take note using game feature of xcode .

so not doing , how can fix ?

uiimage* img1 = [uiimage imagenamed:@"obstacle"]; uiimage* img2 = [uiimage imagenamed:@"obstacle02"]; uiimage* img3 = [uiimage imagenamed:@"obstacle03"]; uiimage* img4 = [uiimage imagenamed:@"obstacle04"];   nsarray *animatearray = [nsarray arraywithobjects:img1,img2,img3,img4, nil];  self.imageview = [[uiimageview alloc]initwithframe:cgrectmake(0, 0, 160, 160)];  self.imageview.animationimages = animatearray;  self.imageview.animationduration = 3.0;  [self.imageview startanimating];  self.imageview.animationrepeatcount = 0;     [self.view addsubview:self.imageview]; 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -