-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNodeStack.swift
More file actions
39 lines (30 loc) · 762 Bytes
/
NodeStack.swift
File metadata and controls
39 lines (30 loc) · 762 Bytes
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
//
// NodeStack.swift
// SpriteKitTest
//
// Created by Christopher Schlitt on 6/8/17.
// Copyright © 2017 Cheeky WWDC. All rights reserved.
//
import Foundation
import SpriteKit
struct NodeStack {
var items = [SKSpriteNode]()
mutating func push(_ node: SKSpriteNode) {
items.append(node)
}
mutating func pop() -> SKSpriteNode {
return items.removeLast()
}
mutating func peek() -> SKSpriteNode {
return items.last!
}
mutating func isEmpty() -> Bool {
return 0 == items.count
}
mutating func removeAtIndex(_ index: Int){
for i in index+1..<items.count {
items[i-1] = items[i]
}
items.removeLast()
}
}