Container can now be assigned an arcade physics body

This commit is contained in:
Richard Davey 2018-04-11 13:37:38 +01:00
parent f80db91429
commit 30d73a0197
2 changed files with 48 additions and 29 deletions

View file

@ -26,6 +26,7 @@ var Vector2 = require('../../math/Vector2');
*
* @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.ComputedSize
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
@ -42,6 +43,7 @@ var Container = new Class({
Mixins: [
Components.Alpha,
Components.BlendMode,
Components.ComputedSize,
Components.Depth,
Components.Transform,
Components.Visible,
@ -130,28 +132,6 @@ var Container = new Class({
*/
this._sortKey = '';
/**
* Internal value to allow Containers to be used for input.
* Do not change this value. It has no effect other than to break input.
*
* @name Phaser.GameObjects.Container#displayOriginX
* @type {number}
* @private
* @since 3.4.0
*/
this.displayOriginX = 0;
/**
* Internal value to allow Containers to be used for input.
* Do not change this value. It has no effect other than to break input.
*
* @name Phaser.GameObjects.Container#displayOriginY
* @type {number}
* @private
* @since 3.4.0
*/
this.displayOriginY = 0;
/**
* Internal value to allow Containers to be used for input.
* Do not change this value. It has no effect other than to break input.
@ -184,6 +164,42 @@ var Container = new Class({
}
},
/**
* Internal value to allow Containers to be used for input and physics.
* Do not change this value. It has no effect other than to break things.
*
* @name Phaser.GameObjects.Container#displayOriginX
* @type {number}
* @readOnly
* @since 3.4.0
*/
displayOriginX: {
get: function ()
{
return this.width * 0.5;
}
},
/**
* Internal value to allow Containers to be used for input and physics.
* Do not change this value. It has no effect other than to break things.
*
* @name Phaser.GameObjects.Container#displayOriginY
* @type {number}
* @readOnly
* @since 3.4.0
*/
displayOriginY: {
get: function ()
{
return this.height * 0.5;
}
},
/**
* Does this Container exclusively manage its children?
*

View file

@ -50,6 +50,9 @@ var Body = new Class({
function Body (world, gameObject)
{
var width = (gameObject.width) ? gameObject.width : 64;
var height = (gameObject.height) ? gameObject.height : 64;
/**
* [description]
*
@ -167,7 +170,7 @@ var Body = new Class({
* @type {Phaser.Math.Vector2}
* @since 3.0.0
*/
this.prev = new Vector2(this.position.x, this.position.y);
this.prev = new Vector2(gameObject.x, gameObject.y);
/**
* [description]
@ -204,7 +207,7 @@ var Body = new Class({
* @type {number}
* @since 3.0.0
*/
this.width = gameObject.width;
this.width = width;
/**
* [description]
@ -213,7 +216,7 @@ var Body = new Class({
* @type {number}
* @since 3.0.0
*/
this.height = gameObject.height;
this.height = height;
/**
* [description]
@ -222,7 +225,7 @@ var Body = new Class({
* @type {number}
* @since 3.0.0
*/
this.sourceWidth = gameObject.width;
this.sourceWidth = width;
/**
* [description]
@ -231,7 +234,7 @@ var Body = new Class({
* @type {number}
* @since 3.0.0
*/
this.sourceHeight = gameObject.height;
this.sourceHeight = height;
if (gameObject.frame)
{
@ -246,7 +249,7 @@ var Body = new Class({
* @type {number}
* @since 3.0.0
*/
this.halfWidth = Math.abs(gameObject.width / 2);
this.halfWidth = Math.abs(width / 2);
/**
* [description]
@ -255,7 +258,7 @@ var Body = new Class({
* @type {number}
* @since 3.0.0
*/
this.halfHeight = Math.abs(gameObject.height / 2);
this.halfHeight = Math.abs(height / 2);
/**
* [description]