In GameViewController
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidLayoutSubviews() {
if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
// Configure the view.
let skView = self.view as 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 to improve rendering performance */
skView.ignoresSiblingOrder = true
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFill
skView.presentScene(scene)
}
}
And in didMoveToView
var hero = SKSpriteNode(color: UIColor.redColor(), size: CGSize(width: 40, height: 40));
let hero_body = SKPhysicsBody(rectangleOfSize: hero.size);
hero.position = CGPoint(x:self.frame.size.width/2, y:50);
self.addChild(hero)
I dont understand how the position work.. when the Y is 50, the rectangle is not showing. Before in xcode 5 with objective-c in order the node to be in bottom of the screen I would do
-self.frame.size.height/2 + hero.size.height/2
But in here this doesn't work