mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added first damage and killing
This commit is contained in:
parent
2a4327c5cf
commit
f22e0dd53d
9 changed files with 124 additions and 52 deletions
|
|
@ -60,6 +60,10 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
|
|||
headShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0, -(this.height - (this.width / 2)) / Settings.RATIO));
|
||||
fixtureDef.shape = headShape;
|
||||
fixtureDef.isSensor = false;
|
||||
fixtureDef.userData = {
|
||||
onCollisionChange: this.onImpact.bind(this)
|
||||
}
|
||||
|
||||
this.body.CreateFixture(fixtureDef);
|
||||
|
||||
var bodyShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
|
|
@ -270,30 +274,8 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
|
|||
};
|
||||
|
||||
Doll.prototype.grab = function(item) {
|
||||
|
||||
this.holdingItem = item;
|
||||
this.positionHoldingItem();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
var item = null;
|
||||
if (this.lookDirection == -1) {
|
||||
item = this.reachableItems.left.shift();
|
||||
} else {
|
||||
item = this.reachableItems.right.shift();
|
||||
}
|
||||
|
||||
if(item) {
|
||||
|
||||
this.holdingItem = item;
|
||||
|
||||
this.positionHoldingItem();
|
||||
}
|
||||
|
||||
|
||||
return item;
|
||||
*/
|
||||
};
|
||||
|
||||
Doll.prototype.positionHoldingItem = function() {
|
||||
|
|
@ -346,6 +328,10 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
|
|||
}
|
||||
}
|
||||
|
||||
Doll.prototype.onImpact = function(isColliding, fixture) {
|
||||
// overwrite if necessary
|
||||
};
|
||||
|
||||
Doll.prototype.onFixtureWithinReach = function(isColliding, side, fixture) {
|
||||
var item = fixture.GetBody().GetUserData();
|
||||
if (!(item instanceof Item)) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue