ios - How do I make a border around my whole screen for all the devices in Swift Xcode? -
i have game thats in landscape , need border around whole screen heronode can't go out of screen on either of 4 sides. have code works iphone 5s , small other devices. how code resize , fit screen other devices? thanks!
override func didmovetoview(view: skview) { let borderbody = skphysicsbody(edgeloopfromrect: cgrect(x: 20, y: -90, width: self.size.width-50, height: self.size.height)) borderbody.categorybitmask = borderbodycategory borderbody.collisionbitmask = herocategory borderbody.contacttestbitmask = herocategory borderbody.allowsrotation = false borderbody.affectedbygravity = false self.physicsbody = borderbody }
you can use uiscreen
's property instead of fixed value.
let width = uiscreen.mainscreen().bounds.size.width - 50 let height = uiscreen.mainscreen().bounds.size.height - 50 let borderbody = skphysicsbody(edgeloopfromrect: cgrect(x: 20, y: -90, width: width, height: height))
Comments
Post a Comment