2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2017-07-27 13:22:44 +00:00
|
|
|
// Phaser.Input.InteractiveObject
|
2017-07-25 03:10:50 +00:00
|
|
|
|
2018-03-19 21:12:11 +00:00
|
|
|
/**
|
|
|
|
* @callback HitAreaCallback
|
|
|
|
*
|
|
|
|
* @param {any} hitArea - [description]
|
|
|
|
* @param {number} x - [description]
|
|
|
|
* @param {number} y - [description]
|
|
|
|
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {object} InteractiveObject
|
|
|
|
*
|
|
|
|
* @property {Phaser.GameObjects.GameObject} gameObject - [description]
|
|
|
|
* @property {boolean} enabled - [description]
|
|
|
|
* @property {boolean} draggable - [description]
|
|
|
|
* @property {boolean} dropZone - [description]
|
|
|
|
* @property {[type]} target - [description]
|
|
|
|
* @property {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
|
|
|
* @property {any} hitArea - [description]
|
|
|
|
* @property {HitAreaCallback} hitAreaCallback - [description]
|
|
|
|
* @property {number} localX - [description]
|
|
|
|
* @property {number} localY - [description]
|
|
|
|
* @property {(0|1|2)} dragState - [description]
|
|
|
|
* @property {number} dragStartX - [description]
|
|
|
|
* @property {number} dragStartY - [description]
|
|
|
|
* @property {number} dragX - [description]
|
|
|
|
* @property {number} dragY - [description]
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Input.Pointer#positionToCamera
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
|
|
|
* @param {any} hitArea - [description]
|
|
|
|
* @param {HitAreaCallback} hitAreaCallback - [description]
|
|
|
|
*
|
|
|
|
* @return {InteractiveObject} [description]
|
|
|
|
*/
|
2017-07-27 13:22:44 +00:00
|
|
|
var InteractiveObject = function (gameObject, hitArea, hitAreaCallback)
|
|
|
|
{
|
|
|
|
return {
|
2017-07-25 03:10:50 +00:00
|
|
|
|
2017-07-27 13:22:44 +00:00
|
|
|
gameObject: gameObject,
|
2017-07-25 03:10:50 +00:00
|
|
|
|
2017-07-27 13:22:44 +00:00
|
|
|
enabled: true,
|
|
|
|
draggable: false,
|
2017-07-27 17:24:04 +00:00
|
|
|
dropZone: false,
|
2017-07-25 03:10:50 +00:00
|
|
|
|
2017-07-27 23:29:04 +00:00
|
|
|
target: null,
|
|
|
|
|
2017-07-28 17:22:57 +00:00
|
|
|
camera: null,
|
|
|
|
|
2017-07-27 13:22:44 +00:00
|
|
|
hitArea: hitArea,
|
|
|
|
hitAreaCallback: hitAreaCallback,
|
2017-07-25 03:10:50 +00:00
|
|
|
|
2017-07-27 13:22:44 +00:00
|
|
|
localX: 0,
|
|
|
|
localY: 0,
|
2017-07-25 03:10:50 +00:00
|
|
|
|
2017-07-27 02:40:58 +00:00
|
|
|
// 0 = Not being dragged
|
|
|
|
// 1 = Being checked for dragging
|
|
|
|
// 2 = Being dragged
|
2017-07-27 13:22:44 +00:00
|
|
|
dragState: 0,
|
|
|
|
|
2017-07-27 23:46:37 +00:00
|
|
|
dragStartX: 0,
|
|
|
|
dragStartY: 0,
|
|
|
|
|
2017-07-27 13:22:44 +00:00
|
|
|
dragX: 0,
|
2018-01-12 17:07:39 +00:00
|
|
|
dragY: 0
|
2017-07-27 13:22:44 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
};
|
2017-07-18 01:36:45 +00:00
|
|
|
|
|
|
|
module.exports = InteractiveObject;
|