swift2 - Swift/Sprite-kit Adding a static hud that is always at the top and bottom, with the moveable game in the middle? -


i have been playing around trying learn spritekit in xcode7. far have level larger screen, hero can move around , camera follows hero moves off the viewable screen area. next i'm trying create hud @ top , bottom of screen. bottom 1 joystick/buttons live.

i tried this:

let hud = skspritenode(color: skcolor.blackcolor(), size: cgsizemake(self.size.width, self.size.height * 0.05)) hud.anchorpoint = cgpointmake(0, 0) hud.position = cgpointmake(0, (self.view?.bounds.height)! - hud.size.height) self.addchild(hud) 

but puts black view @ top of level , can see if walk hero there. means if move bottom, hero walks joystick , buttons off screen.

can please provide direction on how can add huds sprite-kit @ top , bottom of viewable area, while still allowing hero move around level?

swift 3:

this should move hud (suppose sknode) origin anchorpoint (0.5,0.5) of camera cgpoint.zero visible:

override func didsimulatephysics() {         hud.position = cgpoint(x:-self.frame.midx,y:-self.frame.midy) } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -