mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed drop error. added carrier velocity
This commit is contained in:
parent
7aa417dfc8
commit
197c4072c1
3 changed files with 23 additions and 9 deletions
|
|
@ -77,6 +77,15 @@ function (Nc) {
|
||||||
Swiper.prototype.swipeEnd = function(x, y) {
|
Swiper.prototype.swipeEnd = function(x, y) {
|
||||||
var angularVelocity = this.angleSum;
|
var angularVelocity = this.angleSum;
|
||||||
var length = this.lengthSum;
|
var length = this.lengthSum;
|
||||||
|
|
||||||
|
if (this.points.length < 1) {
|
||||||
|
return {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
av: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var p0x = this.points[0].x;
|
var p0x = this.points[0].x;
|
||||||
var p0y = this.points[0].y;
|
var p0y = this.points[0].y;
|
||||||
var sumx = 0;
|
var sumx = 0;
|
||||||
|
|
|
||||||
|
|
@ -359,7 +359,12 @@ function (Parent, Box2D, Settings, CollisionDetector, Item, Nc) {
|
||||||
this.holdingJoint = null;
|
this.holdingJoint = null;
|
||||||
this.holdingItem = null;
|
this.holdingItem = null;
|
||||||
|
|
||||||
item.throw(options);
|
var dollVelocity = {
|
||||||
|
x: this.body.GetLinearVelocity().x
|
||||||
|
y: this.body.GetLinearVelocity().y
|
||||||
|
};
|
||||||
|
|
||||||
|
item.throw(options, dollVelocity);
|
||||||
};
|
};
|
||||||
|
|
||||||
Doll.prototype.isAnotherPlayerNearby = function() {
|
Doll.prototype.isAnotherPlayerNearby = function() {
|
||||||
|
|
|
||||||
|
|
@ -129,13 +129,13 @@ function (Parent, Box2D, Options, Settings, Exception, Nc) {
|
||||||
return this.body.GetWorldCenter();
|
return this.body.GetWorldCenter();
|
||||||
};
|
};
|
||||||
|
|
||||||
Item.prototype.throw = function(options) {
|
Item.prototype.throw = function(options, carrierVelocity) {
|
||||||
var body = this.body;
|
var body = this.body;
|
||||||
body.SetAwake(true);
|
body.SetAwake(true);
|
||||||
|
|
||||||
var vector = new Box2D.Common.Math.b2Vec2(
|
var vector = new Box2D.Common.Math.b2Vec2(
|
||||||
options.x * Settings.MAX_THROW_FORCE / this.options.weight,
|
options.x * Settings.MAX_THROW_FORCE / this.options.weight + carrierVelocity.x,
|
||||||
-options.y * Settings.MAX_THROW_FORCE / this.options.weight
|
-options.y * Settings.MAX_THROW_FORCE / this.options.weight + carrierVelocity.y
|
||||||
);
|
);
|
||||||
this.body.SetLinearVelocity(vector);
|
this.body.SetLinearVelocity(vector);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue