This repository has been archived by the owner on May 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StartScene.swift
74 lines (58 loc) · 1.82 KB
/
StartScene.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// StartScene.swift
// PaddleBattle
//
// Created by Emad Mohamad on 7/6/15.
// Copyright (c) 2015 Apportable. All rights reserved.
//
import Foundation
class StartScene: CCScene, MenuDelegate {
weak var placeHolder1 : CCNode!
weak var placeHolder2 : CCNode!
weak var placeHolder3 : CCNode!
weak var placeHolder4 : CCNode!
var placeHolders = [CCNode]()
var menuNode : Menu!
var players = [PlayerContainer]()
func didLoadFromCCB() {
placeHolders = [placeHolder1, placeHolder2, placeHolder3, placeHolder4]
setupPlayers()
menuNode.delegate = self
}
func setupPlayers() {
// println("Number Of Players \(GameSettings.numberOfPlayers)")
for i in 0..<4 {
var playerContainer = CCBReader.load("PlayerContainer") as! PlayerContainer
playerContainer.position = placeHolders[i].position
playerContainer.setupPlayer(i)
addChild(playerContainer)
players.append(playerContainer)
}
}
func twoPlayers() {
disablePlayer("player3")
disablePlayer("player4")
}
func threePlayers() {
enablePlayer("player4")
disablePlayer("player3")
}
func fourPlayers() {
enablePlayer("player4")
enablePlayer("player3")
}
func disablePlayer(name: String) {
var playerX = getChildByName(name , recursively: false) as! PlayerContainer
playerX.circle.opacity = 0.5
playerX.player.paddle.opacity = 0.0
}
func enablePlayer(name: String) {
var playerX = getChildByName(name , recursively: false) as! PlayerContainer
playerX.circle.opacity = 1
playerX.player.paddle.opacity = 1
}
func continueGame() {
}
func unpauseGame() {
}
}