mirror of
https://github.com/photonstorm/phaser
synced 2024-11-14 00:47:29 +00:00
Mesh based Game Objects can use an input configuration Fixes #6510
This commit is contained in:
parent
36a05e268a
commit
798082c6c6
2 changed files with 29 additions and 13 deletions
|
@ -1157,14 +1157,21 @@ var Mesh = new Class({
|
|||
*
|
||||
* @example
|
||||
* mesh.setInteractive();
|
||||
*
|
||||
* @example
|
||||
* mesh.setInteractive({ useHandCursor: true });
|
||||
*
|
||||
* @method Phaser.GameObjects.Mesh#setInteractive
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {(Phaser.Types.Input.InputConfiguration)} [config] - An input configuration object but it will ignore hitArea, hitAreaCallback and pixelPerfect with associated alphaTolerance properties.
|
||||
*
|
||||
* @return {this} This GameObject.
|
||||
*/
|
||||
setInteractive: function ()
|
||||
setInteractive: function (config)
|
||||
{
|
||||
if (config === undefined) { config = {}; }
|
||||
|
||||
var hitAreaCallback = function (area, x, y)
|
||||
{
|
||||
var faces = this.faces;
|
||||
|
@ -1183,7 +1190,7 @@ var Mesh = new Class({
|
|||
return false;
|
||||
}.bind(this);
|
||||
|
||||
this.scene.sys.input.enable(this, hitAreaCallback);
|
||||
this.scene.sys.input.enable(this, config, hitAreaCallback);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
|
|
@ -2163,22 +2163,31 @@ var InputPlugin = new Class({
|
|||
{
|
||||
var config = hitArea;
|
||||
|
||||
hitArea = GetFastValue(config, 'hitArea', null);
|
||||
hitAreaCallback = GetFastValue(config, 'hitAreaCallback', null);
|
||||
var mesh = gameObjects.some(function (gameObject)
|
||||
{
|
||||
return gameObject.hasOwnProperty('faces');
|
||||
});
|
||||
|
||||
if (!mesh)
|
||||
{
|
||||
hitArea = GetFastValue(config, 'hitArea', null);
|
||||
hitAreaCallback = GetFastValue(config, 'hitAreaCallback', null);
|
||||
|
||||
pixelPerfect = GetFastValue(config, 'pixelPerfect', false);
|
||||
var alphaTolerance = GetFastValue(config, 'alphaTolerance', 1);
|
||||
|
||||
if (pixelPerfect)
|
||||
{
|
||||
hitArea = {};
|
||||
hitAreaCallback = this.makePixelPerfect(alphaTolerance);
|
||||
}
|
||||
}
|
||||
|
||||
draggable = GetFastValue(config, 'draggable', false);
|
||||
dropZone = GetFastValue(config, 'dropZone', false);
|
||||
cursor = GetFastValue(config, 'cursor', false);
|
||||
useHandCursor = GetFastValue(config, 'useHandCursor', false);
|
||||
|
||||
pixelPerfect = GetFastValue(config, 'pixelPerfect', false);
|
||||
var alphaTolerance = GetFastValue(config, 'alphaTolerance', 1);
|
||||
|
||||
if (pixelPerfect)
|
||||
{
|
||||
hitArea = {};
|
||||
hitAreaCallback = this.makePixelPerfect(alphaTolerance);
|
||||
}
|
||||
|
||||
// Still no hitArea or callback?
|
||||
if (!hitArea || !hitAreaCallback)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue