mirror of
https://github.com/photonstorm/phaser
synced 2025-02-27 12:57:15 +00:00
The Layer
Game Object has been given all of the missing properties and methods from Game Object to make the class shapes identical. This includes the properties parentContainer
, tabIndex
, input
and body
. You cannot set any of these properties, they are ignored by the Layer itself. It also includes the methods: setInteractive
, disableInteractive
and removeInteractive
. A Layer cannot be enabled for input or have a physics body. Fix #5459
This commit is contained in:
parent
234b259db7
commit
a19e4770df
1 changed files with 135 additions and 0 deletions
|
@ -152,6 +152,18 @@ var Layer = new Class({
|
|||
*/
|
||||
this.state = 0;
|
||||
|
||||
/**
|
||||
* A Layer cannot be placed inside a Container.
|
||||
*
|
||||
* This property is kept purely so a Layer has the same
|
||||
* shape as a Game Object.
|
||||
*
|
||||
* @name Phaser.GameObjects.Layer#parentContainer
|
||||
* @type {Phaser.GameObjects.Container}
|
||||
* @since 3.51.0
|
||||
*/
|
||||
this.parentContainer = null;
|
||||
|
||||
/**
|
||||
* The name of this Game Object.
|
||||
* Empty by default and never populated by Phaser, this is left for developers to use.
|
||||
|
@ -175,6 +187,17 @@ var Layer = new Class({
|
|||
*/
|
||||
this.active = true;
|
||||
|
||||
/**
|
||||
* The Tab Index of the Game Object.
|
||||
* Reserved for future use by plugins and the Input Manager.
|
||||
*
|
||||
* @name Phaser.GameObjects.Layer#tabIndex
|
||||
* @type {number}
|
||||
* @default -1
|
||||
* @since 3.51.0
|
||||
*/
|
||||
this.tabIndex = -1;
|
||||
|
||||
/**
|
||||
* A Data Manager.
|
||||
* It allows you to store, query and get key/value paired information specific to this Game Object.
|
||||
|
@ -214,6 +237,28 @@ var Layer = new Class({
|
|||
*/
|
||||
this.cameraFilter = 0;
|
||||
|
||||
/**
|
||||
* This property is kept purely so a Layer has the same
|
||||
* shape as a Game Object. You cannot input enable a Layer.
|
||||
*
|
||||
* @name Phaser.GameObjects.Layer#input
|
||||
* @type {?Phaser.Types.Input.InteractiveObject}
|
||||
* @default null
|
||||
* @since 3.51.0
|
||||
*/
|
||||
this.input = null;
|
||||
|
||||
/**
|
||||
* This property is kept purely so a Layer has the same
|
||||
* shape as a Game Object. You cannot give a Layer a physics body.
|
||||
*
|
||||
* @name Phaser.GameObjects.Layer#body
|
||||
* @type {?(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody|MatterJS.BodyType)}
|
||||
* @default null
|
||||
* @since 3.51.0
|
||||
*/
|
||||
this.body = null;
|
||||
|
||||
/**
|
||||
* This Game Object will ignore all calls made to its destroy method if this flag is set to `true`.
|
||||
* This includes calls that may come from a Group, Container or the Scene itself.
|
||||
|
@ -511,6 +556,54 @@ var Layer = new Class({
|
|||
return this.data.get(key);
|
||||
},
|
||||
|
||||
/**
|
||||
* A Layer cannot be enabled for input.
|
||||
*
|
||||
* This method does nothing and is kept to ensure
|
||||
* the Layer has the same shape as a Game Object.
|
||||
*
|
||||
* @method Phaser.GameObjects.Layer#setInteractive
|
||||
* @since 3.51.0
|
||||
*
|
||||
* @return {this} This GameObject.
|
||||
*/
|
||||
setInteractive: function ()
|
||||
{
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* A Layer cannot be enabled for input.
|
||||
*
|
||||
* This method does nothing and is kept to ensure
|
||||
* the Layer has the same shape as a Game Object.
|
||||
*
|
||||
* @method Phaser.GameObjects.Layer#disableInteractive
|
||||
* @since 3.51.0
|
||||
*
|
||||
* @return {this} This GameObject.
|
||||
*/
|
||||
disableInteractive: function ()
|
||||
{
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* A Layer cannot be enabled for input.
|
||||
*
|
||||
* This method does nothing and is kept to ensure
|
||||
* the Layer has the same shape as a Game Object.
|
||||
*
|
||||
* @method Phaser.GameObjects.Layer#removeInteractive
|
||||
* @since 3.51.0
|
||||
*
|
||||
* @return {this} This GameObject.
|
||||
*/
|
||||
removeInteractive: function ()
|
||||
{
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* This callback is invoked when this Game Object is added to a Scene.
|
||||
*
|
||||
|
@ -582,6 +675,48 @@ var Layer = new Class({
|
|||
return !(this.renderFlags !== 15 || this.list.length === 0 || (this.cameraFilter !== 0 && (this.cameraFilter & camera.id)));
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array containing the display list index of either this Game Object, or if it has one,
|
||||
* its parent Container. It then iterates up through all of the parent containers until it hits the
|
||||
* root of the display list (which is index 0 in the returned array).
|
||||
*
|
||||
* Used internally by the InputPlugin but also useful if you wish to find out the display depth of
|
||||
* this Game Object and all of its ancestors.
|
||||
*
|
||||
* @method Phaser.GameObjects.Layer#getIndexList
|
||||
* @since 3.51.0
|
||||
*
|
||||
* @return {number[]} An array of display list position indexes.
|
||||
*/
|
||||
getIndexList: function ()
|
||||
{
|
||||
// eslint-disable-next-line consistent-this
|
||||
var child = this;
|
||||
var parent = this.parentContainer;
|
||||
|
||||
var indexes = [];
|
||||
|
||||
while (parent)
|
||||
{
|
||||
indexes.unshift(parent.getIndex(child));
|
||||
|
||||
child = parent;
|
||||
|
||||
if (!parent.parentContainer)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
parent = parent.parentContainer;
|
||||
}
|
||||
}
|
||||
|
||||
indexes.unshift(this.displayList.getIndex(child));
|
||||
|
||||
return indexes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal method called from `List.addCallback`.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue