ios - Screen's real size is bigger than what i see objective C Xcode -


when make new project on xcode , use game template spaceship game. made easy code see if works add elements, seems real size of screen bigger see. when draw skspirtenode on x , y = 0 or x , y = 10, it's not on screen, it's somewhere outside screen. when let ball bounce, ball goes off screen , comes back, seems somewhere end fix problem. don't want fix using specific numbers set screen because want app run on iphone 6 , iphone 5 well. also, i'd make work portrait , landscape mode.

here code, i'm adding abstract object.

here view controller.m

    @implementation skscene (unarchive)  + (instancetype)unarchivefromfile:(nsstring *)file {     /* retrieve scene file path application bundle */     nsstring *nodepath = [[nsbundle mainbundle] pathforresource:file oftype:@"sks"];     /* unarchive file skscene object */     nsdata *data = [nsdata datawithcontentsoffile:nodepath                                           options:nsdatareadingmappedifsafe                                             error:nil];     nskeyedunarchiver *arch = [[nskeyedunarchiver alloc] initforreadingwithdata:data];     [arch setclass:self forclassname:@"skscene"];     skscene *scene = [arch decodeobjectforkey:nskeyedarchiverootobjectkey];     [arch finishdecoding];      return scene; }  @end  @implementation gameviewcontroller  - (void)viewdidload {     [super viewdidload];      // configure view.     skview * skview = (skview *)self.view;     skview.showsfps = yes;     skview.showsnodecount = yes;     /* sprite kit applies additional optimizations improve rendering performance */     skview.ignoressiblingorder = yes;      // create , configure scene.     gamescene *scene = [gamescene unarchivefromfile:@"gamescene"];     scene.scalemode = skscenescalemodeaspectfill;      // present scene.     [skview presentscene:scene]; }   - (nsuinteger)supportedinterfaceorientations {     if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiomphone) {         return uiinterfaceorientationmaskallbutupsidedown;     } else {         return uiinterfaceorientationmaskall;     } }  - (void)didreceivememorywarning {     [super didreceivememorywarning];     // release cached data, images, etc aren't in use. }  - (bool)prefersstatusbarhidden {     return yes; }  @end 

gamescene.m

#import "gamescene.h"  @implementation gamescene   -(void)didmovetoview:(skview *)view {     /* setup scene here */     self.backgroundcolor = [skcolor colorwithred:0.29 green:0.75 blue:.99 alpha:1];     skspritenode *platform = [skspritenode spritenodewithcolor:[uicolor browncolor] size:cgsizemake(100, 20)];     platform.position = cgpointmake(50, 100);     [self addchild:platform];  }   -(void)update:(cftimeinterval)currenttime {     /* called before each frame rendered */ }  @end 

i've read can add like

scene = gamescene(self.view.frame.size)

but dont know , couldn't find out.

id happy if u can me!


Comments