-
-
Save gsomoza/5506e492adc0da51106ae4674920455e to your computer and use it in GitHub Desktop.
My first P2 impact test code....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.p2world.on('impact', function(evt){ | |
var playerBody, | |
currentPlayer = this.state.players[client.sessionId]; | |
console.log('Body positions: ', evt.bodyA.position, evt.bodyB.position); | |
if (evt.bodyA.hasOwnProperty('playerId')) { | |
playerBody = evt.bodyA; | |
} else if (evt.bodyB.hasOwnProperty('playerId')) { | |
playerBody = evt.bodyB; | |
} else { | |
console.log('who the fuck is moving???'); | |
return; | |
} | |
console.log('Player ID:' + playerBody.playerId); | |
playerBody.velocity = [0, 0]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment