game scene and menu scene are now initialized in states, still need to test for 2 player
This commit is contained in:
parent
0296edb080
commit
8537dee231
@ -19,6 +19,7 @@ class GameState: GKState {
|
|||||||
|
|
||||||
override func didEnter(from previousState: GKState?) {
|
override func didEnter(from previousState: GKState?) {
|
||||||
os_log("Entered Game State", log: LOG, type: .info)
|
os_log("Entered Game State", log: LOG, type: .info)
|
||||||
|
StateManager.stateManager.menuSc!.loadScene(scene: GameScene(size: StateManager.stateManager.menuSc!.size))
|
||||||
}
|
}
|
||||||
|
|
||||||
override func update(deltaTime seconds: TimeInterval) {
|
override func update(deltaTime seconds: TimeInterval) {
|
||||||
|
@ -15,19 +15,8 @@ class GameViewController: UIViewController {
|
|||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
StateManager.stateManager.wantedState = StateTypes.menuSt
|
|
||||||
StateManager.stateManager.createStates()
|
StateManager.stateManager.createStates()
|
||||||
StateManager.stateManager.enterState()
|
StateManager.stateManager.changeState(wantedState: .menuSt, menuSc: nil, gameVC: self)
|
||||||
|
|
||||||
if let view = self.view as! SKView? {
|
|
||||||
let scene = MenuScene(size: self.view.bounds.size)
|
|
||||||
EntityManager.menuEMInstance.setScene(scene: scene)
|
|
||||||
scene.scaleMode = .aspectFill
|
|
||||||
view.presentScene(scene)
|
|
||||||
//TODO: create dev profile or remove on delivery
|
|
||||||
view.showsFPS = true
|
|
||||||
view.showsNodeCount = true
|
|
||||||
}
|
|
||||||
GameCenterManager.sharedInstance.viewController = self
|
GameCenterManager.sharedInstance.viewController = self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,18 +12,46 @@ import os
|
|||||||
class MenuState: GKState {
|
class MenuState: GKState {
|
||||||
|
|
||||||
let LOG = OSLog.init(subsystem: "MenuState", category: "MenuState")
|
let LOG = OSLog.init(subsystem: "MenuState", category: "MenuState")
|
||||||
|
var menuEM = EntityManager.menuEMInstance
|
||||||
|
|
||||||
override func isValidNextState(_ stateClass: AnyClass) -> Bool {
|
override func isValidNextState(_ stateClass: AnyClass) -> Bool {
|
||||||
|
if CommandLine.arguments.contains("--no-matchmaking") {
|
||||||
|
return stateClass is GameState.Type
|
||||||
|
}
|
||||||
return stateClass is SyncingState.Type
|
return stateClass is SyncingState.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
override func update(deltaTime seconds: TimeInterval) {
|
override func update(deltaTime seconds: TimeInterval) {
|
||||||
|
/* if menuEM.entities.count != 0 {
|
||||||
|
menuEM.getBackground()!.update(deltaTime: seconds)
|
||||||
|
menuEM.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterManager.isAuthenticated
|
||||||
|
}
|
||||||
|
|
||||||
|
if GameCenterManager.sharedInstance.initIsFinish {
|
||||||
|
StateManager.stateManager.menuSc!.loadScene(scene: GameCenterManager.sharedInstance.gameScene!)
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override func didEnter(from previousState: GKState?) {
|
override func didEnter(from previousState: GKState?) {
|
||||||
os_log("Entered Menu State", log: LOG, type: .info)
|
os_log("Entered Menu State", log: LOG, type: .info)
|
||||||
|
|
||||||
|
if (previousState == nil){
|
||||||
|
presentFirstViewMenu()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func willExit(to nextState: GKState) {
|
override func willExit(to nextState: GKState) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func presentFirstViewMenu(){
|
||||||
|
if let view = StateManager.stateManager.gameVC!.view as! SKView? {
|
||||||
|
let scene = MenuScene(size: StateManager.stateManager.gameVC!.view.bounds.size)
|
||||||
|
EntityManager.menuEMInstance.setScene(scene: scene)
|
||||||
|
scene.scaleMode = .aspectFill
|
||||||
|
view.presentScene(scene)
|
||||||
|
//TODO: create dev profile or remove on delivery
|
||||||
|
view.showsFPS = true
|
||||||
|
view.showsNodeCount = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import SpriteKit
|
import SpriteKit
|
||||||
import SceneKit
|
import SceneKit
|
||||||
|
|
||||||
class MenuScene: SKScene {
|
class MenuScene: SKScene {
|
||||||
|
|
||||||
var entityManager = EntityManager.menuEMInstance
|
var entityManager = EntityManager.menuEMInstance
|
||||||
@ -23,11 +24,12 @@ class MenuScene: SKScene {
|
|||||||
position: CGPoint(x: midX, y: midY),
|
position: CGPoint(x: midX, y: midY),
|
||||||
onButtonPress: {
|
onButtonPress: {
|
||||||
if CommandLine.arguments.contains("--no-matchmaking") {
|
if CommandLine.arguments.contains("--no-matchmaking") {
|
||||||
self.loadScene(scene: GameScene(size: self.size))
|
StateManager.stateManager.changeState(wantedState: .gameSt, menuSc: self, gameVC: nil)
|
||||||
|
//self.loadScene(scene: GameScene(size: self.size))
|
||||||
SoundManager.sharedInstance.stopMenuMusic()
|
SoundManager.sharedInstance.stopMenuMusic()
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if GameCenterManager.isAuthenticated {
|
if GameCenterManager.isAuthenticated {
|
||||||
|
StateManager.stateManager.changeState(wantedState: .syncingSt, menuSc: self, gameVC: nil)
|
||||||
GameCenterManager.sharedInstance.presentMatchmaker()
|
GameCenterManager.sharedInstance.presentMatchmaker()
|
||||||
}else {
|
}else {
|
||||||
GameCenterManager.sharedInstance.authUser()
|
GameCenterManager.sharedInstance.authUser()
|
||||||
@ -78,4 +80,5 @@ class MenuScene: SKScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user