2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2018-03-19 21:12:11 +00:00
|
|
|
/**
|
2018-06-04 16:11:53 +00:00
|
|
|
* Creates a new Interactive Object.
|
|
|
|
*
|
|
|
|
* This is called automatically by the Input Manager when you enable a Game Object for input.
|
|
|
|
*
|
|
|
|
* The resulting Interactive Object is mapped to the Game Object's `input` property.
|
2018-03-19 21:12:11 +00:00
|
|
|
*
|
2018-03-28 14:03:54 +00:00
|
|
|
* @function Phaser.Input.CreateInteractiveObject
|
2018-03-19 21:12:11 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-06-04 16:11:53 +00:00
|
|
|
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to which this Interactive Object is bound.
|
|
|
|
* @param {any} hitArea - The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle.
|
2019-05-09 11:02:03 +00:00
|
|
|
* @param {Phaser.Types.Input.HitAreaCallback} hitAreaCallback - The 'contains' check callback that the hit area shape will use for all hit tests.
|
2018-03-19 21:12:11 +00:00
|
|
|
*
|
2019-05-09 11:02:03 +00:00
|
|
|
* @return {Phaser.Types.Input.InteractiveObject} The new Interactive Object.
|
2018-03-19 21:12:11 +00:00
|
|
|
*/
|
2018-03-28 14:03:54 +00:00
|
|
|
var CreateInteractiveObject = function (gameObject, hitArea, hitAreaCallback)
|
2017-07-27 13:22:44 +00:00
|
|
|
{
|
|
|
|
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,
|
2018-06-11 10:35:40 +00:00
|
|
|
cursor: 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,
|
2019-07-19 14:16:10 +00:00
|
|
|
hitAreaDebug: null,
|
2017-07-25 03:10:50 +00:00
|
|
|
|
2019-04-24 10:21:52 +00:00
|
|
|
// Has the dev specified their own shape, or is this bound to the texture size?
|
|
|
|
customHitArea: false,
|
|
|
|
|
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,
|
2019-06-19 09:41:26 +00:00
|
|
|
dragStartXGlobal: 0,
|
|
|
|
dragStartYGlobal: 0,
|
2017-07-27 23:46:37 +00:00
|
|
|
|
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
|
|
|
|
2018-03-28 14:03:54 +00:00
|
|
|
module.exports = CreateInteractiveObject;
|