xcode6 - Landscape game using swift in xcode 6 -
in gameviewcontroller
override func viewdidload() { super.viewdidload() } override func viewdidlayoutsubviews() { if allow scene = gamescene.unarchivefromfile("gamescene") as? gamescene { // configure view. allow skview = self.view skview var boo = bool(); boo = true; skview.showsfps = boo; skview.showsnodecount = boo; skview.showsphysics = boo; skview.showsfps = true skview.showsnodecount = true /* sprite kit applies additional optimizations improve rendering performance */ skview.ignoressiblingorder = true /* set scale mode scale fit window */ scene.scalemode = .aspectfill skview.presentscene(scene) } }
and in didmovetoview
var hero = skspritenode(color: uicolor.redcolor(), size: cgsize(width: 40, height: 40)); allow hero_body = skphysicsbody(rectangleofsize: hero.size); hero.position = cgpoint(x:self.frame.size.width/2, y:50); self.addchild(hero)
i dont understand how position work.. when y 50, rectangle not showing. before in xcode 5 objective-c in order node in bottom of screen do
-self.frame.size.height/2 + hero.size.height/2
but in here doesn't work
the comment right. -self.frame.size.height/2 + hero.size.height/2
worked when anchor point cgpointmake(0.5f,0.5f);
seems in case anchor point never changed (0,0). alter it, utilize self.anchorpoint = cgpointmake(0.5f, 0.5f);
method in scene.
swift xcode6 landscape
No comments:
Post a Comment