diff --git a/Pacman3D-iOS/GameViewController.swift b/Pacman3D-iOS/GameViewController.swift index 4b418e304a73852c2ab871887928317b1e24b986..ed2182a3713435cf181c5ef8fca9c172ea5008e5 100644 --- a/Pacman3D-iOS/GameViewController.swift +++ b/Pacman3D-iOS/GameViewController.swift @@ -24,6 +24,11 @@ class GameViewController: UIViewController, SKSceneDelegate ,SCNPhysicsContactDe var direction: Player.Direction = .north + // overlay + var pointsLabel: SKLabelNode! + var lifeLabel: SKLabelNode! + + override func viewDidLoad() { super.viewDidLoad() @@ -92,7 +97,7 @@ class GameViewController: UIViewController, SKSceneDelegate ,SCNPhysicsContactDe scnView.allowsCameraControl = false // show statistics such as fps and timing information - scnView.showsStatistics = true + scnView.showsStatistics = false // configure the view scnView.backgroundColor = UIColor.black @@ -213,11 +218,19 @@ class GameViewController: UIViewController, SKSceneDelegate ,SCNPhysicsContactDe } func createOverlay() -> SKScene { - let scene = SKScene(size: self.view.frame.size) - let node = SKSpriteNode(imageNamed: "run.png") - node.position = CGPoint(x: 100, y: 100) - node.size = CGSize(width: 50, height: 100) - //scene.addChild(node) + let scene = SKScene(size: CGSize(width: self.view.frame.size.height, height: self.view.frame.size.width)) + pointsLabel = SKLabelNode(fontNamed: "Chalkduster") + pointsLabel.text = "0 Punkte" + pointsLabel.fontColor = UIColor.red + pointsLabel.position = CGPoint(x: 100, y: self.view.frame.width - 30) + scene.addChild(pointsLabel) + + lifeLabel = SKLabelNode(fontNamed: "Chalkduster") + lifeLabel.text = "♥️♥️♥️" + lifeLabel.horizontalAlignmentMode = .right + lifeLabel.fontColor = UIColor.red + lifeLabel.position = CGPoint(x: self.view.frame.height - 50, y: 5) + scene.addChild(lifeLabel) return scene } diff --git a/Pacman3D-iOS/Player.swift b/Pacman3D-iOS/Player.swift index 24a897edb21a27812f6886e216df78f035d859a3..efef0c3c873ad03ea4ab095fad24632708b1430d 100644 --- a/Pacman3D-iOS/Player.swift +++ b/Pacman3D-iOS/Player.swift @@ -15,4 +15,7 @@ class Player { case south case west } + + var points: Int = 0 + var life: Int = 3 }