mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
Added custom hitAreaCallback for #6394
This commit is contained in:
parent
f8faec2702
commit
dd98011eb3
1 changed files with 70 additions and 0 deletions
|
@ -364,6 +364,9 @@ var Mesh = new Class({
|
|||
*/
|
||||
this.fov;
|
||||
|
||||
this.displayOriginX = 0;
|
||||
this.displayOriginY = 0;
|
||||
|
||||
var renderer = scene.sys.renderer;
|
||||
|
||||
this.setPosition(x, y);
|
||||
|
@ -1146,6 +1149,73 @@ var Mesh = new Class({
|
|||
return this.setTint();
|
||||
},
|
||||
|
||||
/**
|
||||
* Pass this Mesh Game Object to the Input Manager to enable it for Input.
|
||||
*
|
||||
* Unlike other Game Objects, the Mesh Game Object uses its own special hit area callback, which you cannot override.
|
||||
*
|
||||
* @example
|
||||
* mesh.setInteractive();
|
||||
*
|
||||
* @method Phaser.GameObjects.Mesh#setInteractive
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @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 face = faces[i];
|
||||
|
||||
// Don't pass a calcMatrix, as the x/y are already transformed
|
||||
if (face.contains(x, y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets an additive tint on all vertices of this Mesh Game Object.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue