ios - uiimageview.image not always changing when game over -
ios - uiimageview.image not always changing when game over -
hi iam new coding , start of making simple game in xcode. game done have little problem. @ times when in game on pig.image not alter , previous animation keeps on going after [pig stopanimation]... heres code when game on image should change.....
-(void)gameover1{ [jetpacksound stop]; [self hitsound]; [pig stopanimating]; [movementtimer invalidate]; if (score > highscorenumber) { highscorenumber = score; [[nsuserdefaults standarduserdefaults] setinteger:highscorenumber forkey:@"highscoresaved"]; } else{ highscore.text = [nsstring stringwithformat:@"try harder next time"]; } movementtimer = [nstimer scheduledtimerwithtimeinterval:.035 target:self selector:@selector(gameover1movement) userinfo:nil repeats:yes]; bam.hidden = no; flash.hidden = no; background1.hidden = yes; background2.hidden = yes; background3.hidden = yes; pauseg.hidden = yes; scorelabel.hidden = yes; fork1.hidden = yes; fork2.hidden = yes; fork3.hidden = yes; fork4.hidden = yes; knife1.hidden = yes; knife2.hidden = yes; knife3.hidden = yes; knife4.hidden = yes; poisoncloud.hidden = yes; cake.hidden = yes; } -(void)gameover1movement{ pig.center = cgpointmake(pig.center.x, pig.center.y - 30); if (is_ipad) { //do stuff ipad if (pig.center.y < 400) { [self gameover2]; } } else { if(is_iphone_5) { //do stuff 4 inch iphone screen if (pig.center.y < 200) { [self gameover2]; } } else { //do stuff 3.5 inch iphone screen } } } -(void)gameover2{ [movementtimer invalidate]; movementtimer = [nstimer scheduledtimerwithtimeinterval:.035 target:self selector:@selector(gameover2movement) userinfo:nil repeats:yes]; pig.image = [uiimage imagenamed:@"deadpig.png"]; background1.hidden = no; background2.hidden = no; background3.hidden = no; bam.hidden = yes; flash.hidden = yes; if (is_ipad) { //do stuff ipad pig.frame = cgrectmake(pig.center.x - 115, pig.center.y - 165, 230.0f, 330.0f); if (pig.center.x < 115) { pig.center = cgpointmake(115, pig.center.y); } if (pig.center.x > 653) { pig.center = cgpointmake(653, pig.center.y); } background3.center = cgpointmake(384, 512); background2.center = cgpointmake(384, 1536); background1.center = cgpointmake(384, 2560); } else { if(is_iphone_5) { //do stuff 4 inch iphone screen pig.frame = cgrectmake(pig.center.x - 50, pig.center.y - 75, 100.0f, 150.0f); if (pig.center.x < 50) { pig.center = cgpointmake(50, pig.center.y); } if (pig.center.x > 270) { pig.center = cgpointmake(270, pig.center.y); } background3.center = cgpointmake(160, 284); background2.center = cgpointmake(160, 852); background1.center = cgpointmake(160, 1420); } else { //do stuff 3.5 inch iphone screen } } }
ios objective-c uiimageview
Comments
Post a Comment