mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Mesh and Plane now support setInteractive
. Fix #6394
This commit is contained in:
parent
01f06cddd8
commit
d9e98a7e85
2 changed files with 13 additions and 45 deletions
|
@ -364,6 +364,7 @@ var Mesh = new Class({
|
|||
*/
|
||||
this.fov;
|
||||
|
||||
// Set these to allow setInteractive to work
|
||||
this.displayOriginX = 0;
|
||||
this.displayOriginY = 0;
|
||||
|
||||
|
@ -1163,55 +1164,26 @@ var Mesh = new Class({
|
|||
* @return {this} This GameObject.
|
||||
*/
|
||||
setInteractive: function ()
|
||||
{
|
||||
this.scene.sys.input.enable(this, this.hitAreaCallback.bind(this));
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* The internal hit area callback for this Mesh.
|
||||
*
|
||||
* @method Phaser.GameObjects.Mesh#hitAreaCallback
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @return {this} This GameObject.
|
||||
*/
|
||||
hitAreaCallback: function (area, x, y)
|
||||
{
|
||||
var faces = this.faces;
|
||||
|
||||
for (var i = 0; i < faces.length; i++)
|
||||
var hitAreaCallback = function (area, x, y)
|
||||
{
|
||||
var face = faces[i];
|
||||
|
||||
// Don't pass a calcMatrix, as the x/y are already transformed
|
||||
if (face.contains(x, y))
|
||||
for (var i = 0; i < faces.length; i++)
|
||||
{
|
||||
return true;
|
||||
var face = faces[i];
|
||||
|
||||
// Don't pass a calcMatrix, as the x/y are already transformed
|
||||
if (face.contains(x, y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* If this Mesh Game Object has previously been enabled for input, this will disable it.
|
||||
*
|
||||
* An object that is disabled for input stops processing or being considered for
|
||||
* input events, but can be turned back on again at any time by simply calling
|
||||
* `setInteractive()` with no arguments provided.
|
||||
*
|
||||
* If want to completely remove interaction from this Game Object then use `removeInteractive` instead.
|
||||
*
|
||||
* @method Phaser.GameObjects.Mesh#disableInteractive
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @return {this} This GameObject.
|
||||
*/
|
||||
disableInteractive: function ()
|
||||
{
|
||||
this.scene.sys.input.disable(this);
|
||||
this.scene.sys.input.enable(this, hitAreaCallback);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
|
|
@ -36,10 +36,6 @@ var UUID = require('../../utils/string/UUID');
|
|||
* The Plane Game Object also has the Animation component, allowing you to play animations
|
||||
* across the Plane just as you would with a Sprite.
|
||||
*
|
||||
* While a Plane cannot be enabled for input it does have the methods `hasFaceAt` and
|
||||
* `getFaceAt` which can be used with Pointer coordinates to detect if they have clicked
|
||||
* on Plane face, or not.
|
||||
*
|
||||
* Note that the Plane object is WebGL only and does not have a Canvas counterpart.
|
||||
*
|
||||
* The Plane origin is always 0.5 x 0.5 and cannot be changed.
|
||||
|
|
Loading…
Reference in a new issue