mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
begin Round Bug improvements, player renders doll. fixes #64
This commit is contained in:
parent
55b56f9c12
commit
c18384f502
11 changed files with 76 additions and 42 deletions
|
|
@ -2,10 +2,11 @@ define([
|
|||
"Game/" + GLOBALS.context + "/Physics/Engine",
|
||||
"Game/" + GLOBALS.context + "/Loader/TiledLevel",
|
||||
"Game/" + GLOBALS.context + "/Player",
|
||||
"Lib/Utilities/NotificationCenter"
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Doll",
|
||||
],
|
||||
|
||||
function (PhysicsEngine, TiledLevel, Player, Nc) {
|
||||
function (PhysicsEngine, TiledLevel, Player, Nc, Doll) {
|
||||
|
||||
function GameController (options) {
|
||||
|
||||
|
|
@ -79,8 +80,7 @@ function (PhysicsEngine, TiledLevel, Player, Nc) {
|
|||
return;
|
||||
}
|
||||
|
||||
var i = this.gameObjects.animated.indexOf(player);
|
||||
if(i>=0) this.gameObjects.animated.splice(i, 1);
|
||||
this.onGameObjectRemove('animated', player);
|
||||
|
||||
player.destroy();
|
||||
delete this.players[userId];
|
||||
|
|
@ -105,14 +105,24 @@ function (PhysicsEngine, TiledLevel, Player, Nc) {
|
|||
Nc.off(this.ncTokens[i]);
|
||||
};
|
||||
|
||||
/*
|
||||
* Contents of gameObject: Players, Items, Tiles, RagDolls
|
||||
* No Dolls.
|
||||
*/
|
||||
|
||||
for (var key in this.gameObjects) {
|
||||
for (var i = 0; i < this.gameObjects[key].length; i++) {
|
||||
var gameObject = this.gameObjects[key][i];
|
||||
this.onGameObjectRemove(key, gameObject);
|
||||
|
||||
gameObject.destroy();
|
||||
};
|
||||
};
|
||||
|
||||
this.gameObjects = {
|
||||
fixed: [],
|
||||
animated: []
|
||||
};
|
||||
|
||||
this.physicsEngine.destroy();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ function (Parent, Box2D, Settings, CollisionDetector, Item, Nc) {
|
|||
this.createFixtures();
|
||||
this.body.SetActive(false);
|
||||
|
||||
Nc.trigger(Nc.ns.core.game.gameObject.add, 'animated', this);
|
||||
}
|
||||
|
||||
Doll.prototype = Object.create(Parent.prototype);
|
||||
|
|
@ -372,7 +371,6 @@ function (Parent, Box2D, Settings, CollisionDetector, Item, Nc) {
|
|||
};
|
||||
|
||||
Doll.prototype.destroy = function() {
|
||||
Nc.trigger(Nc.ns.core.game.gameObject.remove, 'animated', this);
|
||||
};
|
||||
|
||||
return Doll;
|
||||
|
|
|
|||
|
|
@ -161,9 +161,6 @@ function (Parent, Box2D, Settings, Nc) {
|
|||
0,
|
||||
options.limbs.upperRightArm.height / 2
|
||||
);
|
||||
|
||||
|
||||
Nc.trigger(Nc.ns.core.game.gameObject.add, 'animated', this);
|
||||
}
|
||||
|
||||
RagDoll.prototype = Object.create(Parent.prototype);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ function (Doll, Settings, Nc, Exception, SpectatorDoll, RagDoll) {
|
|||
this.throw(0, 0, this.holdingItem)
|
||||
}
|
||||
|
||||
// get forces
|
||||
// prepare for creating the ragdoll
|
||||
var options = {
|
||||
x: this.getPosition().x * Settings.RATIO,
|
||||
y: this.getPosition().y * Settings.RATIO,
|
||||
|
|
@ -123,9 +123,6 @@ function (Doll, Settings, Nc, Exception, SpectatorDoll, RagDoll) {
|
|||
this.doll = null;
|
||||
|
||||
this.ragDoll = ragDoll;
|
||||
|
||||
|
||||
Nc.trigger(Nc.ns.core.game.player.killed, this, killedByPlayer);
|
||||
};
|
||||
|
||||
Player.prototype.update = function () {
|
||||
|
|
@ -145,9 +142,14 @@ function (Doll, Settings, Nc, Exception, SpectatorDoll, RagDoll) {
|
|||
}
|
||||
|
||||
this.spectatorDoll.destroy();
|
||||
if(this.doll) this.doll.destroy();
|
||||
|
||||
this.playerController.destroy();
|
||||
if(this.doll) {
|
||||
this.doll.destroy();
|
||||
}
|
||||
|
||||
if(this.playerController) {
|
||||
this.playerController.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
Player.prototype.setPlayerController = function(playerController) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue