phaser/src/input/CreateInteractiveObject.js

64 lines
1.7 KiB
JavaScript
Raw Normal View History

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)
{
return {
gameObject: gameObject,
enabled: true,
draggable: false,
2017-07-27 17:24:04 +00:00
dropZone: false,
2018-06-11 10:35:40 +00:00
cursor: false,
target: null,
camera: null,
hitArea: hitArea,
hitAreaCallback: hitAreaCallback,
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,
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,
dragStartXGlobal: 0,
dragStartYGlobal: 0,
dragX: 0,
dragY: 0
};
};
2018-03-28 14:03:54 +00:00
module.exports = CreateInteractiveObject;