-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.js
More file actions
84 lines (84 loc) · 3.32 KB
/
clean.js
File metadata and controls
84 lines (84 loc) · 3.32 KB
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
75
76
77
78
79
80
81
82
83
84
let clean = {
// Run all cleanup functions
cleanUpAll: function() {
clean.cleanPlayers();
clean.cleanGround();
clean.cleanPlatforms();
clean.cleanBackground();
clean.cleanScreens();
clean.cleanPortraits();
},
// Delete player portraits
cleanPortraits: function () {
while(portraitsGroup.length > 0) { // Because it refuses to run the function on all items in the group
portraitsGroup.forEach(function(portrait) {
portrait.destroy();
}, this);
}
},
// Delete all screens
cleanScreens: function() {
while(displayScreensGroup.length > 0) { // Because it refuses to run the function on all items in the group
displayScreensGroup.forEach(function(displayedScreen) {
displayedScreen.destroy();
}, this);
}
},
cleanPlayer: function(player) {
let group = player.group;
while(group.length > 0) { // Because it refuses to run the function on all items in the group
group.forEach(function(p) {
if (!p) return;
if (p.attackTimer) player.attackTimer.stop();
if (p.attackTimer2) player.attackTimer2.stop();
if (p.attackBox) player.attackBox.destroy();
p.destroy();
}, this);
}
},
// Delete all players from game
cleanPlayers: function() {
while(player1Group.length > 0) { // Because it refuses to run the function on all items in the group
player1Group.forEach(function(player) {
if (!player) return;
if (player.attackTimer) player.attackTimer.stop();
if (player.attackTimer2) player.attackTimer2.stop();
if (player.attackBox) player.attackBox.destroy();
player.destroy();
}, this);
}
while(player2Group.length > 0) { // Because it refuses to run the function on all items in the group
player2Group.forEach(function(player) {
if (!player) return;
if (player.attackTimer) player.attackTimer.stop();
if (player.attackTimer2) player.attackTimer2.stop();
if (player.attackBox) player.attackBox.destroy();
player.destroy();
}, this);
}
},
// Delete all platforms from game
cleanPlatforms: function() {
while(platformGroup.length > 0) { // Because it refuses to run the function on all items in the group
platformGroup.forEach(function(platform) {
platform.destroy();
}, this);
}
},
// Delete all ground from game
cleanGround: function() {
while(groundGroup.length > 0) { // Because it refuses to run the function on all items in the group
groundGroup.forEach(function(ground) {
ground.destroy();
}, this);
}
},
// Delete all backgrounds from game
cleanBackground: function() {
while(backgroundGroup.length > 0) { // Because it refuses to run the function on all items in the group
backgroundGroup.forEach(function(background) {
background.destroy();
}, this);
}
}
};