2017-11-08 17:18:41 +00:00
|
|
|
var CircleContains = require('../../geom/circle/Contains');
|
|
|
|
var Class = require('../../utils/Class');
|
|
|
|
var CONST = require('./const');
|
|
|
|
var Rectangle = require('../../geom/rectangle/Rectangle');
|
|
|
|
var RectangleContains = require('../../geom/rectangle/Contains');
|
|
|
|
var Vector2 = require('../../math/Vector2');
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* @classdesc
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @class Body
|
|
|
|
* @memberOf Phaser.Physics.Arcade
|
|
|
|
* @constructor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Physics.Arcade.World} world - [description]
|
|
|
|
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
var Body = new Class({
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
|
|
|
function Body (world, gameObject)
|
|
|
|
{
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#world
|
|
|
|
* @type {Phaser.Physics.Arcade.World}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.world = world;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#gameObject
|
|
|
|
* @type {Phaser.GameObjects.GameObject}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.gameObject = gameObject;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#debugShowBody
|
|
|
|
* @type {boolean}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.debugShowBody = world.defaults.debugShowBody;
|
2018-02-09 03:44:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#debugShowVelocity
|
|
|
|
* @type {boolean}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.debugShowVelocity = world.defaults.debugShowVelocity;
|
2018-02-09 03:44:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#debugBodyColor
|
|
|
|
* @type {integer}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.debugBodyColor = world.defaults.bodyDebugColor;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#enable
|
|
|
|
* @type {boolean}
|
|
|
|
* @default true
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.enable = true;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#isCircle
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.isCircle = false;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#radius
|
|
|
|
* @type {number}
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.radius = 0;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#offset
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.offset = new Vector2();
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#position
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.position = new Vector2(gameObject.x, gameObject.y);
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#prev
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.prev = new Vector2(this.position.x, this.position.y);
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#allowRotation
|
|
|
|
* @type {boolean}
|
|
|
|
* @default true
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.allowRotation = true;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#rotation
|
|
|
|
* @type {number}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.rotation = gameObject.angle;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#preRotation
|
|
|
|
* @type {number}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.preRotation = gameObject.angle;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#width
|
|
|
|
* @type {number}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.width = gameObject.width;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#height
|
|
|
|
* @type {number}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.height = gameObject.height;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#sourceWidth
|
|
|
|
* @type {number}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.sourceWidth = gameObject.width;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#sourceHeight
|
|
|
|
* @type {number}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.sourceHeight = gameObject.height;
|
|
|
|
|
|
|
|
if (gameObject.frame)
|
|
|
|
{
|
|
|
|
this.sourceWidth = gameObject.frame.realWidth;
|
|
|
|
this.sourceHeight = gameObject.frame.realHeight;
|
|
|
|
}
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#halfWidth
|
|
|
|
* @type {number}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.halfWidth = Math.abs(gameObject.width / 2);
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#halfHeight
|
|
|
|
* @type {number}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.halfHeight = Math.abs(gameObject.height / 2);
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#center
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight);
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#velocity
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.velocity = new Vector2();
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#newVelocity
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.newVelocity = new Vector2();
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#deltaMax
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.deltaMax = new Vector2();
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#acceleration
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.acceleration = new Vector2();
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#allowDrag
|
|
|
|
* @type {boolean}
|
|
|
|
* @default true
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.allowDrag = true;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#drag
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.drag = new Vector2();
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#allowGravity
|
|
|
|
* @type {boolean}
|
|
|
|
* @default true
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.allowGravity = true;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#gravity
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.gravity = new Vector2();
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#bounce
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.bounce = new Vector2();
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#worldBounce
|
|
|
|
* @type {?[type]}
|
|
|
|
* @default null
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.worldBounce = null;
|
|
|
|
|
2017-11-09 04:02:59 +00:00
|
|
|
// If true this Body will dispatch events
|
2018-02-09 03:44:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#onWorldBounds
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
this.onWorldBounds = false;
|
2018-02-09 03:44:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#onCollide
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
this.onCollide = false;
|
2018-02-09 03:44:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#onOverlap
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
this.onOverlap = false;
|
2017-11-08 17:18:41 +00:00
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#maxVelocity
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.maxVelocity = new Vector2(10000, 10000);
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#friction
|
|
|
|
* @type {Phaser.Math.Vector2}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.friction = new Vector2(1, 0);
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#angularVelocity
|
|
|
|
* @type {number}
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.angularVelocity = 0;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#angularAcceleration
|
|
|
|
* @type {number}
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.angularAcceleration = 0;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#angularDrag
|
|
|
|
* @type {number}
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.angularDrag = 0;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#maxAngular
|
|
|
|
* @type {number}
|
|
|
|
* @default 1000
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.maxAngular = 1000;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#mass
|
|
|
|
* @type {number}
|
|
|
|
* @default 1
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.mass = 1;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#angle
|
|
|
|
* @type {number}
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.angle = 0;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#speed
|
|
|
|
* @type {number}
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.speed = 0;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#facing
|
|
|
|
* @type {integer}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.facing = CONST.FACING_NONE;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#immovable
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.immovable = false;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#moves
|
|
|
|
* @type {boolean}
|
|
|
|
* @default true
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.moves = true;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#customSeparateX
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.customSeparateX = false;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#customSeparateY
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.customSeparateY = false;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#overlapX
|
|
|
|
* @type {number}
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.overlapX = 0;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#overlapY
|
|
|
|
* @type {number}
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.overlapY = 0;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#overlapR
|
|
|
|
* @type {number}
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.overlapR = 0;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#embedded
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.embedded = false;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#collideWorldBounds
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.collideWorldBounds = false;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#checkCollision
|
|
|
|
* @type {object}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.checkCollision = { none: false, up: true, down: true, left: true, right: true };
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#touching
|
|
|
|
* @type {object}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.touching = { none: true, up: false, down: false, left: false, right: false };
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#wasTouching
|
|
|
|
* @type {object}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.wasTouching = { none: true, up: false, down: false, left: false, right: false };
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#blocked
|
|
|
|
* @type {object}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.blocked = { none: true, up: false, down: false, left: false, right: false };
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#dirty
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.dirty = false;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#syncBounds
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.syncBounds = false;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#isMoving
|
|
|
|
* @type {boolean}
|
|
|
|
* @default false
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.isMoving = false;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#stopVelocityOnCollide
|
|
|
|
* @type {boolean}
|
|
|
|
* @default true
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this.stopVelocityOnCollide = true;
|
|
|
|
|
2017-11-09 04:02:59 +00:00
|
|
|
// read-only
|
2018-02-09 03:44:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#physicsType
|
|
|
|
* @type {integer}
|
|
|
|
* @readOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-09 15:32:08 +00:00
|
|
|
this.physicsType = CONST.DYNAMIC_BODY;
|
2017-11-08 17:18:41 +00:00
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#_reset
|
|
|
|
* @type {boolean}
|
|
|
|
* @private
|
|
|
|
* @default true
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this._reset = true;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#_sx
|
|
|
|
* @type {number}
|
|
|
|
* @private
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this._sx = gameObject.scaleX;
|
2018-02-09 03:44:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#_sy
|
|
|
|
* @type {number}
|
|
|
|
* @private
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this._sy = gameObject.scaleY;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#_dx
|
|
|
|
* @type {number}
|
|
|
|
* @private
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this._dx = 0;
|
2018-02-09 03:44:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#_dy
|
|
|
|
* @type {number}
|
|
|
|
* @private
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this._dy = 0;
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#_bounds
|
|
|
|
* @type {Phaser.Geom.Rectangle}
|
|
|
|
* @private
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
this._bounds = new Rectangle();
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#updateBounds
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
updateBounds: function ()
|
|
|
|
{
|
|
|
|
var sprite = this.gameObject;
|
|
|
|
|
|
|
|
if (this.syncBounds)
|
|
|
|
{
|
|
|
|
var b = sprite.getBounds(this._bounds);
|
|
|
|
|
|
|
|
if (b.width !== this.width || b.height !== this.height)
|
|
|
|
{
|
|
|
|
this.width = b.width;
|
|
|
|
this.height = b.height;
|
|
|
|
this._reset = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var asx = Math.abs(sprite.scaleX);
|
|
|
|
var asy = Math.abs(sprite.scaleY);
|
|
|
|
|
|
|
|
if (asx !== this._sx || asy !== this._sy)
|
|
|
|
{
|
|
|
|
this.width = this.sourceWidth * asx;
|
|
|
|
this.height = this.sourceHeight * asy;
|
|
|
|
this._sx = asx;
|
|
|
|
this._sy = asy;
|
|
|
|
this._reset = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._reset)
|
|
|
|
{
|
|
|
|
this.halfWidth = Math.floor(this.width / 2);
|
|
|
|
this.halfHeight = Math.floor(this.height / 2);
|
|
|
|
this.updateCenter();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#updateCenter
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
updateCenter: function ()
|
|
|
|
{
|
|
|
|
this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight);
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#update
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} delta - [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
update: function (delta)
|
|
|
|
{
|
|
|
|
this.dirty = true;
|
|
|
|
|
|
|
|
// Store and reset collision flags
|
|
|
|
this.wasTouching.none = this.touching.none;
|
|
|
|
this.wasTouching.up = this.touching.up;
|
|
|
|
this.wasTouching.down = this.touching.down;
|
|
|
|
this.wasTouching.left = this.touching.left;
|
|
|
|
this.wasTouching.right = this.touching.right;
|
|
|
|
|
|
|
|
this.touching.none = true;
|
|
|
|
this.touching.up = false;
|
|
|
|
this.touching.down = false;
|
|
|
|
this.touching.left = false;
|
|
|
|
this.touching.right = false;
|
|
|
|
|
|
|
|
this.blocked.none = true;
|
|
|
|
this.blocked.up = false;
|
|
|
|
this.blocked.down = false;
|
|
|
|
this.blocked.left = false;
|
|
|
|
this.blocked.right = false;
|
|
|
|
|
|
|
|
this.overlapR = 0;
|
|
|
|
this.overlapX = 0;
|
|
|
|
this.overlapY = 0;
|
|
|
|
|
|
|
|
this.embedded = false;
|
|
|
|
|
|
|
|
this.updateBounds();
|
|
|
|
|
|
|
|
var sprite = this.gameObject;
|
|
|
|
|
|
|
|
this.position.x = sprite.x - sprite.displayOriginX + (sprite.scaleX * this.offset.x);
|
|
|
|
this.position.y = sprite.y - sprite.displayOriginY + (sprite.scaleY * this.offset.y);
|
|
|
|
|
|
|
|
this.updateCenter();
|
|
|
|
|
|
|
|
this.rotation = sprite.angle;
|
|
|
|
|
|
|
|
this.preRotation = this.rotation;
|
|
|
|
|
|
|
|
if (this._reset)
|
|
|
|
{
|
|
|
|
this.prev.x = this.position.x;
|
|
|
|
this.prev.y = this.position.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.moves)
|
|
|
|
{
|
|
|
|
this.world.updateMotion(this);
|
|
|
|
|
|
|
|
this.newVelocity.set(this.velocity.x * delta, this.velocity.y * delta);
|
|
|
|
|
|
|
|
this.position.x += this.newVelocity.x;
|
|
|
|
this.position.y += this.newVelocity.y;
|
|
|
|
|
|
|
|
this.updateCenter();
|
|
|
|
|
|
|
|
if (this.position.x !== this.prev.x || this.position.y !== this.prev.y)
|
|
|
|
{
|
|
|
|
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y);
|
|
|
|
|
|
|
|
// Now the State update will throw collision checks at the Body
|
|
|
|
// And finally we'll integrate the new position back to the Sprite in postUpdate
|
|
|
|
|
2017-11-13 01:04:35 +00:00
|
|
|
if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds)
|
2017-11-08 17:18:41 +00:00
|
|
|
{
|
2018-01-12 17:09:09 +00:00
|
|
|
this.world.emit('worldbounds', this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right);
|
2017-11-08 17:18:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this._dx = this.deltaX();
|
|
|
|
this._dy = this.deltaY();
|
|
|
|
|
|
|
|
this._reset = false;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* Feeds the body results back into the parent gameobject.
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#postUpdate
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
postUpdate: function ()
|
|
|
|
{
|
|
|
|
// Only allow postUpdate to be called once per frame
|
|
|
|
if (!this.enable || !this.dirty)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.dirty = false;
|
|
|
|
|
|
|
|
if (this.deltaX() < 0)
|
|
|
|
{
|
|
|
|
this.facing = CONST.FACING_LEFT;
|
|
|
|
}
|
|
|
|
else if (this.deltaX() > 0)
|
|
|
|
{
|
|
|
|
this.facing = CONST.FACING_RIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.deltaY() < 0)
|
|
|
|
{
|
|
|
|
this.facing = CONST.FACING_UP;
|
|
|
|
}
|
|
|
|
else if (this.deltaY() > 0)
|
|
|
|
{
|
|
|
|
this.facing = CONST.FACING_DOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.moves)
|
|
|
|
{
|
|
|
|
this._dx = this.deltaX();
|
|
|
|
this._dy = this.deltaY();
|
|
|
|
|
|
|
|
if (this.deltaMax.x !== 0 && this._dx !== 0)
|
|
|
|
{
|
|
|
|
if (this._dx < 0 && this._dx < -this.deltaMax.x)
|
|
|
|
{
|
|
|
|
this._dx = -this.deltaMax.x;
|
|
|
|
}
|
|
|
|
else if (this._dx > 0 && this._dx > this.deltaMax.x)
|
|
|
|
{
|
|
|
|
this._dx = this.deltaMax.x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.deltaMax.y !== 0 && this._dy !== 0)
|
|
|
|
{
|
|
|
|
if (this._dy < 0 && this._dy < -this.deltaMax.y)
|
|
|
|
{
|
|
|
|
this._dy = -this.deltaMax.y;
|
|
|
|
}
|
|
|
|
else if (this._dy > 0 && this._dy > this.deltaMax.y)
|
|
|
|
{
|
|
|
|
this._dy = this.deltaMax.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.gameObject.x += this._dx;
|
|
|
|
this.gameObject.y += this._dy;
|
|
|
|
|
|
|
|
this._reset = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateCenter();
|
|
|
|
|
|
|
|
if (this.allowRotation)
|
|
|
|
{
|
|
|
|
this.gameObject.angle += this.deltaZ();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.prev.x = this.position.x;
|
|
|
|
this.prev.y = this.position.y;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#checkWorldBounds
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
checkWorldBounds: function ()
|
|
|
|
{
|
|
|
|
var pos = this.position;
|
|
|
|
var bounds = this.world.bounds;
|
|
|
|
var check = this.world.checkCollision;
|
|
|
|
|
|
|
|
var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x;
|
|
|
|
var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y;
|
|
|
|
|
|
|
|
if (pos.x < bounds.x && check.left)
|
|
|
|
{
|
|
|
|
pos.x = bounds.x;
|
|
|
|
this.velocity.x *= bx;
|
|
|
|
this.blocked.left = true;
|
|
|
|
this.blocked.none = false;
|
|
|
|
}
|
|
|
|
else if (this.right > bounds.right && check.right)
|
|
|
|
{
|
|
|
|
pos.x = bounds.right - this.width;
|
|
|
|
this.velocity.x *= bx;
|
|
|
|
this.blocked.right = true;
|
|
|
|
this.blocked.none = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pos.y < bounds.y && check.up)
|
|
|
|
{
|
|
|
|
pos.y = bounds.y;
|
|
|
|
this.velocity.y *= by;
|
|
|
|
this.blocked.up = true;
|
|
|
|
this.blocked.none = false;
|
|
|
|
}
|
|
|
|
else if (this.bottom > bounds.bottom && check.down)
|
|
|
|
{
|
|
|
|
pos.y = bounds.bottom - this.height;
|
|
|
|
this.velocity.y *= by;
|
|
|
|
this.blocked.down = true;
|
|
|
|
this.blocked.none = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return !this.blocked.none;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setOffset
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} x - [description]
|
|
|
|
* @param {number} y - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-11 03:52:23 +00:00
|
|
|
setOffset: function (x, y)
|
2017-11-08 17:18:41 +00:00
|
|
|
{
|
2017-11-11 03:52:23 +00:00
|
|
|
if (y === undefined) { y = x; }
|
|
|
|
|
|
|
|
this.offset.set(x, y);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setSize
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} width - [description]
|
|
|
|
* @param {number} height - [description]
|
|
|
|
* @param {boolean} [center=true] - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-11 03:52:23 +00:00
|
|
|
setSize: function (width, height, center)
|
|
|
|
{
|
|
|
|
if (center === undefined) { center = true; }
|
2017-11-08 17:18:41 +00:00
|
|
|
|
|
|
|
this.sourceWidth = width;
|
|
|
|
this.sourceHeight = height;
|
2017-11-11 03:52:23 +00:00
|
|
|
|
2017-11-08 17:18:41 +00:00
|
|
|
this.width = this.sourceWidth * this._sx;
|
|
|
|
this.height = this.sourceHeight * this._sy;
|
2017-11-11 03:52:23 +00:00
|
|
|
|
2017-11-08 17:18:41 +00:00
|
|
|
this.halfWidth = Math.floor(this.width / 2);
|
|
|
|
this.halfHeight = Math.floor(this.height / 2);
|
|
|
|
|
|
|
|
this.updateCenter();
|
|
|
|
|
2017-11-11 03:52:23 +00:00
|
|
|
if (center && this.gameObject.getCenter)
|
|
|
|
{
|
|
|
|
var gameObject = this.gameObject;
|
|
|
|
|
|
|
|
var ox = gameObject.displayWidth / 2;
|
|
|
|
var oy = gameObject.displayHeight / 2;
|
|
|
|
|
|
|
|
this.offset.set(ox - this.halfWidth, oy - this.halfHeight);
|
|
|
|
}
|
|
|
|
|
2017-11-08 17:18:41 +00:00
|
|
|
this.isCircle = false;
|
|
|
|
this.radius = 0;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setCircle
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} radius - [description]
|
|
|
|
* @param {number} [offsetX] - [description]
|
|
|
|
* @param {number} [offsetY] - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
setCircle: function (radius, offsetX, offsetY)
|
|
|
|
{
|
|
|
|
if (offsetX === undefined) { offsetX = this.offset.x; }
|
|
|
|
if (offsetY === undefined) { offsetY = this.offset.y; }
|
|
|
|
|
|
|
|
if (radius > 0)
|
|
|
|
{
|
|
|
|
this.isCircle = true;
|
|
|
|
this.radius = radius;
|
|
|
|
|
|
|
|
this.sourceWidth = radius * 2;
|
|
|
|
this.sourceHeight = radius * 2;
|
|
|
|
|
|
|
|
this.width = this.sourceWidth * this._sx;
|
|
|
|
this.height = this.sourceHeight * this._sy;
|
|
|
|
|
|
|
|
this.halfWidth = Math.floor(this.width / 2);
|
|
|
|
this.halfHeight = Math.floor(this.height / 2);
|
|
|
|
|
|
|
|
this.offset.set(offsetX, offsetY);
|
|
|
|
|
|
|
|
this.updateCenter();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.isCircle = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#reset
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} x - [description]
|
|
|
|
* @param {number} y - [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
reset: function (x, y)
|
|
|
|
{
|
|
|
|
this.stop();
|
|
|
|
|
|
|
|
var sprite = this.gameObject;
|
|
|
|
|
2017-11-09 04:02:59 +00:00
|
|
|
this.position.x = x - sprite.displayOriginX + (sprite.scaleX * this.offset.x);
|
|
|
|
this.position.y = y - sprite.displayOriginY + (sprite.scaleY * this.offset.y);
|
2017-11-08 17:18:41 +00:00
|
|
|
|
|
|
|
this.prev.x = this.position.x;
|
|
|
|
this.prev.y = this.position.y;
|
|
|
|
|
|
|
|
this.rotation = this.gameObject.angle;
|
|
|
|
this.preRotation = this.rotation;
|
|
|
|
|
|
|
|
this.updateBounds();
|
|
|
|
this.updateCenter();
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#stop
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
stop: function ()
|
|
|
|
{
|
|
|
|
this.velocity.set(0);
|
|
|
|
this.acceleration.set(0);
|
|
|
|
this.speed = 0;
|
|
|
|
this.angularVelocity = 0;
|
|
|
|
this.angularAcceleration = 0;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#getBounds
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {object} obj - [description]
|
|
|
|
*
|
|
|
|
* @return {object} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
getBounds: function (obj)
|
|
|
|
{
|
|
|
|
obj.x = this.x;
|
|
|
|
obj.y = this.y;
|
|
|
|
obj.right = this.right;
|
|
|
|
obj.bottom = this.bottom;
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#hitTest
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} x - [description]
|
|
|
|
* @param {number} y - [description]
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
hitTest: function (x, y)
|
|
|
|
{
|
|
|
|
return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y);
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#onFloor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
onFloor: function ()
|
|
|
|
{
|
|
|
|
return this.blocked.down;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#onCeiling
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
onCeiling: function ()
|
|
|
|
{
|
|
|
|
return this.blocked.up;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#onWall
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
onWall: function ()
|
|
|
|
{
|
|
|
|
return (this.blocked.left || this.blocked.right);
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#deltaAbsX
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {number} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
deltaAbsX: function ()
|
|
|
|
{
|
|
|
|
return (this.deltaX() > 0) ? this.deltaX() : -this.deltaX();
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#deltaAbsY
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {number} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
deltaAbsY: function ()
|
|
|
|
{
|
|
|
|
return (this.deltaY() > 0) ? this.deltaY() : -this.deltaY();
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#deltaX
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {number} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
deltaX: function ()
|
|
|
|
{
|
|
|
|
return this.position.x - this.prev.x;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#deltaY
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {number} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
deltaY: function ()
|
|
|
|
{
|
|
|
|
return this.position.y - this.prev.y;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#deltaZ
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {number} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
deltaZ: function ()
|
|
|
|
{
|
|
|
|
return this.rotation - this.preRotation;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#destroy
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
destroy: function ()
|
|
|
|
{
|
|
|
|
this.gameObject.body = null;
|
|
|
|
this.gameObject = null;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#drawDebug
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.GameObjects.Graphics} graphic - [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
drawDebug: function (graphic)
|
|
|
|
{
|
|
|
|
var pos = this.position;
|
2017-11-11 03:52:23 +00:00
|
|
|
var x = pos.x + this.halfWidth;
|
|
|
|
var y = pos.y + this.halfHeight;
|
2017-11-08 17:18:41 +00:00
|
|
|
|
|
|
|
if (this.debugShowBody)
|
|
|
|
{
|
2017-11-11 03:52:23 +00:00
|
|
|
graphic.lineStyle(1, this.debugBodyColor);
|
|
|
|
|
|
|
|
if (this.isCircle)
|
|
|
|
{
|
|
|
|
graphic.strokeCircle(x, y, this.radius);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
graphic.strokeRect(pos.x, pos.y, this.width, this.height);
|
|
|
|
}
|
2017-11-08 17:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.debugShowVelocity)
|
|
|
|
{
|
|
|
|
graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1);
|
2017-11-09 23:56:12 +00:00
|
|
|
graphic.lineBetween(x, y, x + this.velocity.x / 2, y + this.velocity.y / 2);
|
2017-11-08 17:18:41 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#willDrawDebug
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
willDrawDebug: function ()
|
|
|
|
{
|
|
|
|
return (this.debugShowBody || this.debugShowVelocity);
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setCollideWorldBounds
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {boolean} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setCollideWorldBounds: function (value)
|
|
|
|
{
|
|
|
|
this.collideWorldBounds = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setVelocity
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} x - [description]
|
|
|
|
* @param {number} y - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setVelocity: function (x, y)
|
|
|
|
{
|
|
|
|
this.velocity.set(x, y);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setVelocityX
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setVelocityX: function (value)
|
|
|
|
{
|
|
|
|
this.velocity.x = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setVelocityY
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setVelocityY: function (value)
|
|
|
|
{
|
|
|
|
this.velocity.y = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setBounce
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} x - [description]
|
|
|
|
* @param {number} y - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setBounce: function (x, y)
|
|
|
|
{
|
|
|
|
this.bounce.set(x, y);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setBounceX
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setBounceX: function (value)
|
|
|
|
{
|
|
|
|
this.bounce.x = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setBounceY
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setBounceY: function (value)
|
|
|
|
{
|
|
|
|
this.bounce.y = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setAcceleration
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} x - [description]
|
|
|
|
* @param {number} y - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setAcceleration: function (x, y)
|
|
|
|
{
|
|
|
|
this.acceleration.set(x, y);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setAccelerationX
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setAccelerationX: function (value)
|
|
|
|
{
|
|
|
|
this.acceleration.x = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setAccelerationY
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setAccelerationY: function (value)
|
|
|
|
{
|
|
|
|
this.acceleration.y = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setDrag
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} x - [description]
|
|
|
|
* @param {number} y - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setDrag: function (x, y)
|
|
|
|
{
|
|
|
|
this.drag.set(x, y);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setDragX
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setDragX: function (value)
|
|
|
|
{
|
|
|
|
this.drag.x = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setDragY
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setDragY: function (value)
|
|
|
|
{
|
|
|
|
this.drag.y = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setGravity
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} x - [description]
|
|
|
|
* @param {number} y - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setGravity: function (x, y)
|
|
|
|
{
|
|
|
|
this.gravity.set(x, y);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setGravityX
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setGravityX: function (value)
|
|
|
|
{
|
|
|
|
this.gravity.x = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setGravityY
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setGravityY: function (value)
|
|
|
|
{
|
|
|
|
this.gravity.y = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setFriction
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} x - [description]
|
|
|
|
* @param {number} y - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setFriction: function (x, y)
|
|
|
|
{
|
|
|
|
this.friction.set(x, y);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setFrictionX
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setFrictionX: function (value)
|
|
|
|
{
|
|
|
|
this.friction.x = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setFrictionY
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setFrictionY: function (value)
|
|
|
|
{
|
|
|
|
this.friction.y = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setAngularVelocity
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setAngularVelocity: function (value)
|
|
|
|
{
|
|
|
|
this.angularVelocity = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setAngularAcceleration
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setAngularAcceleration: function (value)
|
|
|
|
{
|
|
|
|
this.angularAcceleration = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setAngularDrag
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setAngularDrag: function (value)
|
|
|
|
{
|
|
|
|
this.angularDrag = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setMass
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setMass: function (value)
|
|
|
|
{
|
|
|
|
this.mass = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Arcade.Body#setImmovable
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {boolean} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
|
|
|
*/
|
2017-11-09 04:02:59 +00:00
|
|
|
setImmovable: function (value)
|
|
|
|
{
|
|
|
|
this.immovable = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#x
|
|
|
|
* @type {number}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
x: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
|
|
|
return this.position.x;
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value)
|
|
|
|
{
|
|
|
|
this.position.x = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#y
|
|
|
|
* @type {number}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
y: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
|
|
|
return this.position.y;
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value)
|
|
|
|
{
|
|
|
|
this.position.y = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#left
|
|
|
|
* @type {number}
|
|
|
|
* @readOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
left: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
|
|
|
return this.position.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#right
|
|
|
|
* @type {number}
|
|
|
|
* @readOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
right: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
|
|
|
return this.position.x + this.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#top
|
|
|
|
* @type {number}
|
|
|
|
* @readOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
top: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
|
|
|
return this.position.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Body#bottom
|
|
|
|
* @type {number}
|
|
|
|
* @readOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-08 17:18:41 +00:00
|
|
|
bottom: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
|
|
|
return this.position.y + this.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = Body;
|