forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateInteractiveObject.js
More file actions
84 lines (70 loc) · 2.2 KB
/
Copy pathCreateInteractiveObject.js
File metadata and controls
84 lines (70 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @callback HitAreaCallback
*
* @param {*} hitArea - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
*
* @return {boolean} [description]
*/
/**
* @typedef {object} Phaser.Input.InteractiveObject
*
* @property {Phaser.GameObjects.GameObject} gameObject - [description]
* @property {boolean} enabled - [description]
* @property {boolean} draggable - [description]
* @property {boolean} dropZone - [description]
* @property {?Phaser.GameObjects.GameObject} target - [description]
* @property {Phaser.Cameras.Scene2D.Camera} camera - [description]
* @property {*} 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]
*
* @function Phaser.Input.CreateInteractiveObject
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
* @param {*} hitArea - [description]
* @param {HitAreaCallback} hitAreaCallback - [description]
*
* @return {Phaser.Input.InteractiveObject} [description]
*/
var CreateInteractiveObject = function (gameObject, hitArea, hitAreaCallback)
{
return {
gameObject: gameObject,
enabled: true,
draggable: false,
dropZone: false,
target: null,
camera: null,
hitArea: hitArea,
hitAreaCallback: hitAreaCallback,
localX: 0,
localY: 0,
// 0 = Not being dragged
// 1 = Being checked for dragging
// 2 = Being dragged
dragState: 0,
dragStartX: 0,
dragStartY: 0,
dragX: 0,
dragY: 0
};
};
module.exports = CreateInteractiveObject;