-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollisions.js
More file actions
32 lines (30 loc) · 1.41 KB
/
collisions.js
File metadata and controls
32 lines (30 loc) · 1.41 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
let collisions = {
collide: function () {
// Collide players with ground
game.physics.arcade.collide(player1Group, groundGroup);
game.physics.arcade.collide(player2Group, groundGroup);
// Collide players with each other
game.physics.arcade.collide(player1Group, player2Group);
},
overlap: function () {
// Allows out of bounds characters to be detected
game.physics.arcade.overlap(player1Group, worldWrapGroup);
game.physics.arcade.overlap(player2Group, worldWrapGroup);
// Allow hitboxs to be detected on other players
game.physics.arcade.overlap(player1Group, player2AttackGroup);
game.physics.arcade.overlap(player2Group, player1AttackGroup);
// Allows for detection of hitbox overlap
game.physics.arcade.overlap(player1AttackGroup, player2AttackGroup);
},
// Check if hitbox collided with player or other hitbox
playerCollide: function (bounds, otherTarget) {
// Collided with the player
if (otherTarget.group && (otherTarget.group === player1Group || otherTarget.group === player2Group)) {
//console.log('dealing dmg');
characters.dealDamage(bounds, otherTarget);
} else { // Assume it collided with hitbox? maybe fine tune detection later
//console.log('clashing players');
controller.clashPlayers(bounds, otherTarget);
}
}
};