mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
Repaired Collision detecteion by adding one detector for each user - fixes #15
This commit is contained in:
parent
a1e94e1ed0
commit
f07505bc20
9 changed files with 31 additions and 29 deletions
|
|
@ -5,20 +5,11 @@ define([
|
|||
|
||||
function (Box2D, Parent) {
|
||||
|
||||
function Detector (me) {
|
||||
Parent.call(this);
|
||||
this.me = me;
|
||||
function Detector (player) {
|
||||
Parent.call(this, player);
|
||||
}
|
||||
|
||||
Detector.prototype = Object.create(Parent.prototype);
|
||||
|
||||
Detector.prototype.handleStand = function (point, isColliding) {
|
||||
if (point.GetFixtureA().GetUserData() == Detector.IDENTIFIER.PLAYER_FOOT_SENSOR
|
||||
|| point.GetFixtureB().GetUserData() == Detector.IDENTIFIER.PLAYER_FOOT_SENSOR) {
|
||||
|
||||
this.me.onFootSensorDetection(isColliding);
|
||||
}
|
||||
}
|
||||
|
||||
return Detector;
|
||||
});
|
||||
|
|
@ -65,6 +65,8 @@ function (Parent, PhysicsEngine, ViewController, KeyboardController, Notificatio
|
|||
//this.onSpawnPlayer(options);
|
||||
this.me = this.players[playerId];
|
||||
this.keyboardController = new KeyboardController(this.me, this);
|
||||
|
||||
this.physicsEngine.setCollisionDetector(this.me);
|
||||
}
|
||||
|
||||
GameController.prototype.onSpawnPlayer = function(options) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ function (ProtocolHelper, GameController, User, NotificationCenter) {
|
|||
NotificationCenter.on("sendGameCommand", this.sendGameCommand, this);
|
||||
}
|
||||
|
||||
|
||||
// Socket callbacks
|
||||
|
||||
Networker.prototype.onConnect = function () {
|
||||
|
|
@ -64,6 +65,7 @@ function (ProtocolHelper, GameController, User, NotificationCenter) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Sending commands
|
||||
|
||||
Networker.prototype.sendCommand = function (command, options) {
|
||||
|
|
@ -76,6 +78,7 @@ function (ProtocolHelper, GameController, User, NotificationCenter) {
|
|||
this.sendCommand('gameCommand', message);
|
||||
}
|
||||
|
||||
|
||||
// Commands from server
|
||||
|
||||
Networker.prototype.onUserJoined = function (userId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue