phaser/src/input/CreateInteractiveObject.js

85 lines
2.2 KiB
JavaScript
Raw Normal View History

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}
*/
2018-03-19 21:12:11 +00:00
/**
* @callback HitAreaCallback
*
2018-03-20 16:15:49 +00:00
* @param {*} hitArea - [description]
2018-03-19 21:12:11 +00:00
* @param {number} x - [description]
* @param {number} y - [description]
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
2018-03-19 21:27:16 +00:00
*
* @return {boolean} [description]
2018-03-19 21:12:11 +00:00
*/
/**
2018-03-28 14:03:54 +00:00
* @typedef {object} Phaser.Input.InteractiveObject
2018-03-19 21:12:11 +00:00
*
* @property {Phaser.GameObjects.GameObject} gameObject - [description]
* @property {boolean} enabled - [description]
* @property {boolean} draggable - [description]
* @property {boolean} dropZone - [description]
2018-03-30 11:02:08 +00:00
* @property {?Phaser.GameObjects.GameObject} target - [description]
2018-03-19 21:12:11 +00:00
* @property {Phaser.Cameras.Scene2D.Camera} camera - [description]
2018-03-20 16:15:49 +00:00
* @property {*} hitArea - [description]
2018-03-19 21:12:11 +00:00
* @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]
*
2018-03-28 14:03:54 +00:00
* @function Phaser.Input.CreateInteractiveObject
2018-03-19 21:12:11 +00:00
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
2018-03-20 16:15:49 +00:00
* @param {*} hitArea - [description]
2018-03-19 21:12:11 +00:00
* @param {HitAreaCallback} hitAreaCallback - [description]
*
2018-03-28 14:03:54 +00:00
* @return {Phaser.Input.InteractiveObject} [description]
2018-03-19 21:12:11 +00:00
*/
2018-03-28 14:03:54 +00:00
var CreateInteractiveObject = function (gameObject, hitArea, hitAreaCallback)
{
return {
gameObject: gameObject,
enabled: true,
draggable: false,
2017-07-27 17:24:04 +00:00
dropZone: false,
target: null,
camera: null,
hitArea: hitArea,
hitAreaCallback: hitAreaCallback,
localX: 0,
localY: 0,
2017-07-27 02:40:58 +00:00
// 0 = Not being dragged
// 1 = Being checked for dragging
// 2 = Being dragged
dragState: 0,
dragStartX: 0,
dragStartY: 0,
dragX: 0,
dragY: 0
};
};
2018-03-28 14:03:54 +00:00
module.exports = CreateInteractiveObject;