xcode - Sprite Kit creating a new screen (Restart Method) -
i testing game on method when u tap display sides across the right side of screen (self.frame.size.width) center(self.frame.size.width/2) when u tap again sides (self.frame.size.width)(off screen)
instead of changing varibles in reset method want create new scene of same scene.
gamescene* newscene = [gamescene scenewithsize:self.view.bounds.size]; newscene.scalemode = skscenescalemodeaspectfill; [self.view presentscene:newscene];
my viewcontroller
scene.scalemode = skscenescalemodeaspectfill;
it works (its suppose off screen) , size increased.
-(void)touchesbegan:(nsset *)touches withevent:(uievent *)event { [self gameover]; if(direction == 1){ [self reset]; } [self endinterface]; (uitouch *touch in touches) { location = [touch locationinnode:self]; } [self handledirectionchange]; } -(void)gameover{ [score_display runaction:[skaction moveto:cgpointmake(self.frame.size.width/2, self.frame.size.height/2+50) duration:0.30]]; [scorefinal runaction:[skaction moveto:cgpointmake(self.frame.size.width/2, self.frame.size.height/2+50) duration:0.30]]; [highscorefinal runaction:[skaction moveto:cgpointmake(self.frame.size.width/2, self.frame.size.height/2-35) duration:0.30]]; [score_retry runaction:[skaction moveto:cgpointmake(self.frame.size.width/2, self.frame.size.height/2-120) duration:0.40]]; [score_rate runaction:[skaction moveto:cgpointmake(self.frame.size.width/2, self.frame.size.height/2-220) duration:0.55]]; [score_share runaction:[skaction moveto:cgpointmake(self.frame.size.width/2, self.frame.size.height/2-300) duration:0.75]]; } -(void)reset{ [score_display runaction:[skaction moveto:score_displayxy duration:0.30]]; [scorefinal runaction:[skaction moveto:cgpointmake(self.frame.size.width, self.frame.size.height/2+50) duration:0.30]]; [highscorefinal runaction:[skaction moveto:cgpointmake(self.frame.size.width, self.frame.size.height/2-35) duration:0.30]]; [score_retry runaction:[skaction moveto:score_retryxy duration:0.40]]; [score_rate runaction:[skaction moveto:score_ratexy duration:0.55]]; [score_share runaction:[skaction moveto:score_sharexy duration:0.75]]; gamescene* newscene = [gamescene scenewithsize:self.view.bounds.size]; newscene.scalemode = skscenescalemodeaspectfill; [self.view presentscene:newscene]; }
as stated in comments, issue view might distorted because of aspect ratio
solution:
replace
gamescene* newscene = [gamescene scenewithsize:self.view.bounds.size];
with
gamescene* newscene = [gamescene scenewithsize:self.frame.size];
Comments
Post a Comment