sprite kit - SpriteKit Swift Positioning HUD -


i'm trying position simple black box use reference hud elements game. positioning of off, y position of box. tried position hud box @ top of screen , spawn whole width, cgrectgetmaxy(screensize) positions @ bottom of screen.

var hudlayer = skspritenode(color: skcolor.blackcolor(), size: cgsizemake(self.size.width, 200))             hudlayer.anchorpoint = cgpointmake(0, 1)             hudlayer.position = cgpointmake(cgrectgetminx(screensize), cgrectgetmaxy(screensize))             hudlayer.zposition = 100             self.addchild(hudlayer) 

how did manage maxy coordinate @ bottom? i'm perplexed , have tried other methods of y-positioning (self.size.height). far, find myself having multiply cgrectgetmaxy(screensize) 3.6 top, i'd rather not.

any explanation why y-coordinates incredibly off? set anchor point, should using upper-left corner position itself. issue can't make same on 4s. on 4s simulator, hud bar appears lower, despite using screensize calculate relative position.

thanks.

your problem sounds skscene's size isn't same skview's size. fix should set scene's size , scale mode:

scene.scalemode = .aspectfill scene.size = skview.bounds.size 

the easiest place set in gameviewcontroller, when you're setting skscene. alternatively though, set in didmovetoview method, in skscene.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -